Data Structures & AlgorithmsHardProduct-company placement
Lectures occupy half-open intervals [start, end): [3, 10), [6, 10), [7, 12), [9, 11), [10, 15), [10, 17), [10, 18), [20, 25). A lecture ending at t frees its room for one starting at t. What is the minimum number of rooms needed?
- A. 5
- B. 7
- C. 3
- D. 4
Correct answer: A. 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
- A binary max-heap is stored in a 0-indexed array [57, 47, 54, 14, 15, 6, 21]. Perform, in order: delete-max, insert 10, delete-max, insert…
- Keys 13, 30, 35, 39, 54 are searched with frequencies 8, 1, 9, 9, 12 respectively (only successful searches). The cost of a BST is Σ…
- A min-heap holds 63 distinct keys in a 0-indexed array (a full tree with 6 levels). At how many different indices can the 5th-smallest key…
- Keys 20, 94, 97, 28, 21, 78, 37, 93, 79, 36 are inserted into an empty AVL tree (giving preorder 78, 28, 21, 20, 37, 36, 93, 79, 94, 97)…
- Dijkstra's algorithm runs from A on the directed graph A→B (14), A→C (11), A→D (8), A→E (1), A→F (15), B→C (6), B→E (2), B→F (5), C→D (9)…
- Bellman–Ford runs from A on the directed graph whose edges are relaxed in EVERY pass in this fixed order: E→D (9), A→B (6), F→A (-3), F→D…