1.Easy
In a graph, what is a cycle?
- AA vertex with no edges
- BA path that starts and ends at the same vertex
- CA path that visits every vertex
- DAn edge with a weight of zero
2.Easy
What is a weighted graph?
- AA graph in which each edge has a numeric value such as a cost or distance
- BA graph in which some vertices are heavier than others because they have more edges
- CA graph that is stored on disk
- DA graph with more edges than vertices
3.Easy
What is the defining feature of a set as an abstract data type?
- AIt stores elements without duplicates
- BIt stores elements in sorted order
- CIt stores key-value pairs
- DIt allows access only at one end
4.Medium
An application needs fast lookups and also needs to list keys in sorted order and answer range queries. Which structure fits best?
- AA stack
- BA hash table
- CA balanced binary search tree
- DAn unsorted linked list
5.Medium
What is the cost of inserting an element in the middle of an array of n elements?
- AO(1), because the index is known
- BO(n), because later elements must shift
- CO(n²), because each element moves n times
- DO(log n), because of binary search
6.Medium
How long does it take to check whether the edge (u, v) exists using an adjacency matrix?
- AO(1)
- BO(E)
- CO(V)
- DO(log V)
7.Hard
The keys 5, 3, 8, 1 are inserted in this order into an empty array-based binary min-heap. What is the final array?
- A[1, 5, 8, 3]
- B[3, 1, 8, 5]
- C[1, 3, 5, 8]
- D[1, 3, 8, 5]
8.Hard
How can you detect whether a singly linked list contains a cycle using O(1) extra memory?
- AStore every visited node in a hash set
- BMove one pointer by one step and another by two steps and check whether they meet
- CCount the nodes until the count exceeds the list length field
- DSort the list and look for duplicates
Answer key
- 1. B · A path that starts and ends at the same vertex
- 2. A · A graph in which each edge has a numeric value such as a cost or distance
- 3. A · It stores elements without duplicates
- 4. C · A balanced binary search tree
- 5. B · O(n), because later elements must shift
- 6. A · O(1)
- 7. D · [1, 3, 8, 5]
- 8. B · Move one pointer by one step and another by two steps and check whether they meet
Full step-by-step solutions: practise this topic on examproblems.com.