Data Structures & AlgorithmsHardProduct-company placement
Lectures occupy half-open intervals [start, end): [5, 13), [8, 13), [8, 16), [13, 16), [13, 17), [13, 18), [13, 20), [17, 22). A lecture ending at t frees its room for one starting at t. What is the minimum number of rooms needed?
- A. 7
- B. 3
- C. 4
- D. 5
Correct answer: D. 5
Sweep the times, processing an end before a start at the same instant; the peak number of overlapping lectures is 5. Treating touching intervals as overlapping gives 7.
Practise more Trees, Graphs, Recursion and Dynamic Programming questionsTrees, Graphs, Recursion and Dynamic Programming: notes and key points
More Trees, Graphs, Recursion and Dynamic Programming questions
- Dijkstra's algorithm runs from A on the directed graph A→D (7), B→A (6), B→E (9), C→A (3), C→D (10), D→B (11), D→F (7), E→C (9), F→A (1)…
- A tree on vertices 1–9 has edges 2–1, 3–1, 4–1, 5–3, 6–3, 7–6, 8–7, 9–6. What are its diameter and radius, and which vertex/vertices form…
- A 4 × 4 grid has rows 3 6 2 5 / 6 9 2 3 / 8 7 2 2 / 4 2 4 9. Moving only right or down from the top-left to the bottom-right cell, what is…
- The words trial, tripod, trie, trip, tried, tree are inserted into an empty trie (one node per character, shared prefixes share nodes…
- Keys 19, 93, 16, 51, 81, 18, 92, 41 inserted in this order build a BST. How many of the 8! orderings of these same 8 keys, inserted into…
- Keys 92, 49, 31, 85, 28, 73, 29, 81, 90 are inserted in that order into an empty AVL tree. What is the preorder traversal of the final tree?