4.3 Fundamentals of Algorithims Flashcards
What are the 2 features of a breadth first graph traversal?
Shortest path for an unweighted graph
uses a queue
What are the 2 features of a depth first graph traversal?
Navigating a maze
uses a stack
pre order tree traversal order
Node, Left, Right -
post order tree traversal
Left, Right, Node -
in order tree traversal and when its used (1)
Left, Node, Right -
Used in binary search trees
What is Meant by O(N)
O represents the order of complexity
N represents the number of inputs
What are the factors of complexity used in big o notation
Memory used, time clompexity
Time complexity of linear search
O(n)
Time complexity of Binary/Binary tree search
O(log n).
Time complexity of Bubble sort
O(n^2).
Time complexity of Merge sort
O(n log n).
What is djikstras algorithim?
Finds the shortest path between one node and all other nodes on a weighted graph.
It is considered a type of breadth first algorithim
What does it mean when algorithims are tractable?
These are problems that have a polynomial (or less) time solution (x^2)
What is it when an algorithim is intractable?
These are problems that have solutions in greater than polynomial time
What methods are used when tackling intractable problems
Heuristic methods
How do we trace a graph depth first
Start at a root and follow one branch as far as it will go. (using stack)
How do we trace a graph breadth-first
start at root scan every node connected and then continue scanning from left to right (using queue)
What are heuristic methods
give 2 examples
practical approaches used when finding an optimal solution is impractical or impossible due to time constraints
For example trial and error, pattern recognition
Describe the traversing of a graph breadth first using a queue
Set the root node as current node
Add current node to list of visited nodes
For every edge connected to that node enqueue the linked node
Then dequeue the current node and move front pointer up by one and repeat steps with the new current node
output all visited nodes
Describe the traversing of a graph depth frist using a stack
Visited nodes are pushed onto the stack, when there are no nodes left to visit the nodes are popped off the stack.