retagged by
1,101 views
2 votes
2 votes

A priority queue is implemented as a Max-Heap. Initially, it has $5$ elements. 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. The level-order traversal of the heap after the insertion of the elements is

  1. $10,8,7,3,2,1,5$
  2. $10,8,7,2,3,1,5$
  3. $10,8,7,1,2,3,5$
  4. $10,8,7,5,3,2,1$
retagged by

2 Answers

0 votes
0 votes

Its MAX heap. Before insertion, BFS was 10,8,5,3,2. On insertion maintain the property of complete tree plus max heap. Thus the bfs traversal will be 10,8,7,3,2,1,5. Hence option A is correct

Answer:

Related questions

2.1k
views
0 answers
5 votes
admin asked Mar 30, 2020
2,080 views
What does the following function do for a given Linked List with first node as head? void fun1(struct node* head) { if(head==NULL) return ... list in reverse orderPrints alternate nodes of Linked ListPrints alternate nodes in reverse order
1.7k
views
0 answers
4 votes
admin asked Mar 30, 2020
1,668 views
Consider the following function that takes reference to head of a Doubly Linked List as parameter. Assume that a node of doubly linked list has ...
1.3k
views
4 answers
2 votes
admin asked Mar 30, 2020
1,325 views
Let $A$ be a square matrix of size $n\times n$. Consider the following program. What is the expected output?C=100 for i=1 to n do for j=1 to ... upper diagonal elements and subtracting $100$ from diagonal elements of $A$.None of the option.
1.3k
views
3 answers
4 votes
admin asked Mar 30, 2020
1,289 views
Assume that the operators $+,-,\times$ are left associative and $\wedge$ is right associative. The order of precedence(from highest to lowest) is $\wedge,\times, +,-$. ... $-+a\times bc\wedge\wedge def$