In this module, we will cover heap operations, priority queues, and top K problems. You will learn how to implement and utilize heaps to solve various problems.
- Heap operations
- Priority queues
- Top K problems
- Kth Largest Element in Array
- K Closest Points to Origin
- Min Cost to Connect Sticks
-
What is the time complexity of inserting an element into a max heap?
- A) O(1)
- B) O(log n)
- C) O(n)
-
How do you find the Kth largest element in an unsorted array?
- A) Sort the array and return the Kth element
- B) Use a min heap of size K
- C) Both A and B
-
What is a priority queue?
- A) A queue that processes elements in FIFO order
- B) A data structure that allows for the efficient retrieval of the highest (or lowest) priority element
- C) A stack that follows LIFO order
-
In a max heap, which of the following statements is true?
- A) The parent node is always smaller than the child nodes
- B) The parent node is always larger than the child nodes
- C) All nodes are arranged in ascending order
-
What is the minimum cost to connect all sticks of lengths 1, 2, 3, and 4?
- A) 9
- B) 10
- C) 7