221 test old questions
Which data structure does not support unsuccessful search in O(log(n)) time in the worst case
Skip Lists
Consider a weighted, undirected and connected graph implemented as an adjacency matrix. What is the running time of the Prim's algorithm for MST? Assume that the Minimum Priority Queue is implemented as an unsorted list with an efficient performance of the decrease_key() functi
O(n^2)
What is the value of the shortest path from the vertex E to the vertex D? A -> D -> C -> B B -> D C -> D -> E D -> E E -> A
2
Use DFS to classify the edges in the graph below represented as an adjacency list. Start DFS at the vertex E and follow the adjacency list. How many forward edges are in the graph? A -> D -> C -> B B -> D C -> D -> E D -> E E -> A `
0
Use DFS to classify the edges in the graph below represented as an adjacency list. Start DFS at the vertex E and follow the adjacency list. How many strongly connected components are in the graph? A -> D -> C -> B B -> D C -> D -> E D -> E E -> A
1
Use DFS to classify the edges in the graph below represented as an adjacency list. Start DFS at the vertex E and follow the adjacency list. How many cross edges are in the graph? A -> D -> C -> B B -> D C -> D -> E D -> E E -> A
2
Use DFS to find the topological sort for the graph below represented as an adjacency list. Start DFS at the vertex 1 and follow the adjacency list. 1 -> 2 -> 6 2 -> 6 3 -> empty 4 -> 5 5 -> empty 6 -> 3 -> 4 -> 7 -> 8 7 -> 3 -> 5 8 -> empty
1, 2, 6, 8, 7, 4, 5, 3 - push to queue when you terminate
What is the predecessor vertex to the vertex D on the shortest path from the vertex E to the vertex D? A -> D -> C -> B B -> D C -> D -> E D -> E E -> A
A
Which algorithm should be used to find the shortest path from E to D for the graph below? A -> D -> C -> B B -> D C -> D -> E D -> E E -> A
BFS - unweighted and undirected graph
When does the Dijkstra's algorithm provide the correct solution to the SSSP problem?
No edges with negative weights
The expected number of comparisons for the delete operation in a skip list is
O(log(n))
Assume that the graph is represented as an adjacency matrix with n vertices. How many comparisons does it take to find a single vertex indegree?
O(n)
Assume that a graph is represented as an adjacency list with n vertices and m edges. How many comparisons does it take to find a single vertex indegree?
O(n+m)
What is the running time of the Dijkstra's algorithm under the assumptions that the graph is implemented as an adjacency matrix and Minimum Priority Queue is implemented as a binary heap. The symbol n denotes the number of vertices.
O(n^2 * log(n))
Are the topological orders generated by DFS and by the algorithm based on in-degree zero for the graph below the same?
True
Is the statement below true? "The topological sort can be introduced in a directed graph only if there are no back edges in the graph"
True
which data structure is non deterministic
skip lists
Can a given undirected, connected and weighted graph have more than one MST?
Yes
Which data structure could be used to implement the disjoint sets data structure
doubly linked list with augmented nodes
Select the skip lists operation which is based on a random function. (search, insert, delete)
insert, HT coin flip
Which the Disjoint Sets operation is used by the Kruskal's algorithm to create singleton sets.
make_set()
Is the topological sort unique for this graph? 1 -> 2 -> 6 2 -> 6 3 -> empty 4 -> 5 5 -> empty 6 -> 3 -> 4 -> 7 -> 8 7 -> 3 -> 5 8 -> empty
no
which data structure is not part of a dictionary
queue
What is the purpose of the find_set() operation used by the Kruskal's algorithm?
return the identifier of the set