edited by
9,586 views
38 38 votes

Consider any array representation of an $n$ element binary heap where the elements are stored from index $1$ to index $n$ of the array. For the element stored at index $i$ of the array $(i \leq n)$, the index of the parent is

  1. $i-1$
  2. $\lfloor \frac{i}{2} \rfloor$
  3. $\lceil \frac{i}{2} \rceil$
  4. $\frac{(i+1)}{2}$

2 Answers

Best answer
53 53 votes
for node at index $i$

left $child(L)$ at $2$i

right $child(R)$ at $2i+1$

for node at index $i$

parent will be at floor $i/2$

Correct Answer: $B$
edited by
6 6 votes
ans b)
Answer:
Position:
Show:

Related questions

38 38 votes
7 answers 7 answers
31.2k
31.2k views
Kathleen asked Sep 14, 2014
31,207 views
What is the minimum number of stacks of size $n$ required to implement a queue of size $n$?OneTwoThreeFour
39 39 votes
3 answers 3 answers
15.1k
15.1k views
Kathleen asked Sep 14, 2014
15,088 views
Which of the following requires a device driver?RegisterCacheMain memoryDisk
49 49 votes
3 answers 3 answers
18.7k
18.7k views
Kathleen asked Sep 14, 2014
18,655 views
Where does the swap space reside?RAMDiskROMOn-chip cache
45 45 votes
2 answers 2 answers
15.7k
15.7k views
Kathleen asked Sep 14, 2014
15,676 views
The process of assigning load addresses to the various parts of the program and adjusting the code and the data in the program to reflect the assigned addresses is called...