Chapter 0, 1 (intro) Flashcards
Deciding on the proper algorithm
Analyze underlying characteristics of problem
Design algorithm according to characteristics of problem, NOT types of problems
What is an algorithm?
Sequence of unambiguous instructions for solving a problem in the finite amount of time
Fundamentals of algorithmic problem solving
Problem -> Algorithm -> (input-> ‘computation’ -> output)
|
Definiteness
Finiteness
Effectiveness
Euler path
A path that uses every edge of the graph exactly once. The path starts and ends at different vertices
Euler circuit
an Euler path that starts and ends at the same vertex
Analysis of algorithms is the determination of the amount of ____ and ____ resources required to execute it
time
space
Efficiency or running time of algorithm is stated as a function relating input size to the number of steps, known as ___ ___, or volume of memory, knowm as ____ ____
time complexity
space complexity
Programming paradigm
Procedural
state the order in which to execute instructions (how to compute the answer)
Programming paradigm
Declarative
does not state the order in which to execute instruction, instead, declare properties of the desired result (not how to compute the answer)
Data Structures
Storing and organizing data so data can be accessed efficiently
- Linear Data structures
* Arrays (static vs. dynamic)
* Linked Lists (Singly vs doubly)
- stacks
- Trees
- Graphs
- Sets and Dictionaries
An array contains ____ _____
homogeneous elements
Static array
allocated at compile time, its size must be a compile time constant.
Size of array is allocated on the stack
Dynamic array
allocated at run time.
Size is allocated on the heap.
May be allocated and then de-allocated multiple times
A linked list contains nodes and each node stores its elements
Singly linked list
Doubly linked list
Circularly linked list
Writing code for Linked Lists
A class define the node
A class define the linked list
Using head and tail to construct linked lists
Operations on the linked list
Operations on Singly Linked List
- SinglyLinkedList()
- ~SinglyLinkedList()
- bool empty()
- addFront(item)
- removeFront()
- displaySinglyLinkedList()
Singly linked list acting like stack
First in Last out (FILO)
Doubly Linked List operations
– DoublyLinkedList();
– ~DoublyLinkedList();
– bool empty();
– void addFront(dNode& newNode);
– void addBack(dNode& newNode);
– void removeFront();
– void removeBack();
– void displayDoublyLinkedListFromFront();
– void displayDoublyLinkedListFromBack();
A circularly linked list has the same kind of nodes as a
singly linked list.
The nodes of a circularly linked list are linked into a ______
cycle
Arrays are faster than linked lists because they use an ____ _____
array index
____ ____ are faster if an element must be removed from the middle of inserted into the middle
Linked lists
Stacks
LIFO (last-in first-out)
stack operation:
push(e)
Insert element e at the top of the stack