...
GATE 2021 CS-Set-1
October 9, 2023
Computer-Networks
October 9, 2023
GATE 2021 CS-Set-1
October 9, 2023
Computer-Networks
October 9, 2023

Data-Structures

Question 35

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≤n), the index of the parent is

A
i-1
B
⌊i/2⌋
C
⌈i/2⌉
D
(i+1)/2
Question 35 Explanation: 
Parent Node is at index: ⌊i/2⌋
Left Child is at index: 2i
Right child is at index: 2*i+1
Correct Answer: B
Question 35 Explanation: 
Parent Node is at index: ⌊i/2⌋
Left Child is at index: 2i
Right child is at index: 2*i+1

Leave a Reply

Your email address will not be published. Required fields are marked *