Recent questions tagged binary-heap

9 9 votes
1 1 answer
207
207 views
Heaps are usually implemented using arrays.If an element is present at a known array index in a heap of size $N$, what is the time complexity to remove that element and r...
2 2 votes
1 1 answer
158
158 views
A max-heap is stored using $0$-based indexing as:$$[60, 30, 45, 15, 5, 10, 20]$$During the first iteration of heap sort:Swap the root with the last element. Reduce the he...
4 4 votes
2 2 answers
151
151 views
A min-heap is stored using $1$-based indexing as:$[2, 13, 7, 17, 14, 22, 8, 21]$After one $\texttt{DeleteMin}$ operation, what is the final heap array?$[7, 13, 8, 17, 14,...
4 4 votes
2 2 answers
167
167 views
The following max-heap is stored using $1$-based indexing:$[57, 53, 42, 48, 25, 34, 29, 18, 30, 25]$Insert $55$ into this max-heap. What is the final heap array?$[57, 55,...
6 6 votes
1 1 answer
143
143 views
Consider the following binary min-heap:Perform the following operations in order:$\text{DeleteMin}$ $\text{Insert 8}$ $\text{Insert 2}$ What is the final array representa...
6 6 votes
1 1 answer
139
139 views
A binary heap is stored in an array using $\textbf{1}$-based indexing. If a node is stored at location $i$ and it has two children, where is its left child stored?$\left\...
5 5 votes
3 3 answers
1.7k
1.7k views
Let $n$ be an odd number greater than $100$. Consider a binary minheap with $n$ elements stored in an array $P$ whose index starts from $1$.Which of the following indices...
1 1 vote
1 1 answer
496
496 views
Consider a min heap containing $n$ elements represented as an array, where $n>100$ and $n$ is odd.Assuming $1$-based indexing, which of the following cannot be the index ...
0 0 votes
1 answers 1 answer
351
351 views
1 1 vote
0 0 answers
221
221 views
Which of the following is the primary property of a binary heap?The parent node is greater than its children (max-heap).The parent node is less than its children (min-hea...
2 2 votes
1 1 answer
209
209 views
Which of the following operations can be performed in $\mathrm{O}(\log n)$ time in a binary heap?Deleting the root elementInserting an elementBoth $\text{(A)}$ and $\text...
0 0 votes
1 1 answer
391
391 views
If the largest value in a max-heap is in the root node and the second-largest value is in the root's right child, what will be the number of positions where the fourth-la...
1 1 vote
1 1 answer
358
358 views
  If the largest value in a max-heap is in the root node and the second-largest value is in the root's right child, what will be the number of positions where the fourth...