Fundamentals of Algorithms Flashcards
What is depth-first traversal of graphs?
Explores the graph as far a possible, then backtracking to visit unvisited nodes.
How is depth-first graph traversal implemented?
Using a recursive algorithm.
Using stacks , when a node is visited it is placed on the stack and if there are no more nodes attached to them they are popped off the stack.
What are the uses of depth-first graph traversals?
Finding a route between two nodes
Exploring a maze.
What is breadth-first graph traversal?
Visits to nodes closest to the starting point first.
How are breadth-first graph traversals implemented?
Queues keep track of the nodes to visit.
What are the uses of breadth-first graph traversals?
Social and peer-to-peer networks.
What is pre-order traversal of a binary tree?
Root
Left
Right
What is in-order traversal of a binary tree?
Left
Root
Right
What is post-order traversal of a binary tree?
Left
Right
Root
What does the in-order traversal of binary tree produce?
Alphabetical order
What does the post-order traversal of binary tree produce?
Reverse Polish Notation
What is recursion?
The process of calling a function from within itself.
What is the base/terminating case of recursion?
It defines the point at which the recursive function will stop calling itself.
What is Dijkstra’s shortest path algorithm?
An algorithm that calculates the shortest distance between two points.
What is Dijkstra’s shortest path algorithm used for in terms of graphs?
Used to calculate the shortest path between the starting node and all other nodes on weighted graphs.