Consider a 1-based array representation of an n-element binary heap, where…

GATE · Computer Science · 2001

Consider a 1-based array representation of an n-element binary heap, where elements are stored from index 1 to index n. For a non-root element stored at index i (1 < i <= n), the index of its parent is:

  1. A.

    i - 1

  2. B.

    ⌊i / 2⌋

  3. C.

    ⌈i / 2⌉

  4. D.

    (i + 1) / 2

Attempted by 295 students.

Show answer

Correct answer: B

The worked solution is available to enrolled students.

Explore the full course: Iocl Engineers Officers Grade A Paper 2

Loading lesson…