MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A Priority-Queue is implemented as a Max-Heap. Initially, it has 5 elements. The level-order traversal of the heap is given below:10, 8, 5, 3, 2Two new elements “1” and “7” are inserted in the heap in that order. The level-order traversal of the heap after the insertion of the elements is:
A
10, 8, 7, 5, 3, 2, 1
B
10, 8, 7, 2, 3, 1, 5
C
10, 8, 7, 1, 2, 3, 5
D
10, 8, 7, 3, 2, 1, 5
Explanation: 

Detailed explanation-1: -A priority queue is implemented as a max-heap initially, it has five elements. The level-order traversal of the heap is as follows: 20, 18, 15, 13, 12. Two new elements ‘10’ and ‘17’ are inserted in the heap in that order, The level-order traversal of the heap after the insertion of the element is.

Detailed explanation-2: -The binary heap is the most efficient method for implementing the priority queue in the data structure.

Detailed explanation-3: -The level order traversal of the heap is 10, 8, 5, 3, 2. Two new elements ‘1’ and ‘7’ are inserted into the heap in that order.

Detailed explanation-4: -We can use heaps to implement the priority queue. It will take O(log N) time to insert and delete each element in the priority queue. Based on heap structure, priority queue also has two types max-priority queue and min-priority queue.

There is 1 question to complete.