Chapter 30 Flashcards
1
Q
What is the difference between stack and queue
A
In stack, the elements who goes first, comes out last (LIFO)
In queue, the elements who goes first, comes out first (FIFO)
2
Q
What is total time of depth-first traversal
A
O(E) (it is polynomial time)
3
Q
What is the time of finding all neighbors of vertex in line 7, if graph is represented using adjacency matrix
A
O(V) time
4
Q
Does DFS and BFS always yield a tree
A
Yes