• edited by
9,634 views
25 25 votes

Which of the following sequences of array elements forms a heap?

  1. $\{23, 17, 14, 6, 13, 10, 1, 12, 7, 5\}$
  2. $\{23, 17, 14, 6, 13, 10, 1, 5, 7, 12\}$
  3. $\{23, 17, 14, 7, 13, 10, 1, 5, 6, 12\}$
  4. $\{23, 17, 14, 7, 13, 10, 1, 12, 5, 7\}$

1 Answer

Best answer
28 28 votes

For a heap(max heap) parent should be greater than or equal to children. in a heap of $[1..n]$ left child of ith node will be at $2*i$ th position and right child will be at $2*i+1$ position.

So, for given options we can verify it.
.
Option C seems to be following the property.

• edited by
Answer:
Position:
Show:

Related questions

52 52 votes
3 answers 3 answers
14.3k
14.3k views
Ishrat Jahan asked Nov 1, 2014
14,282 views
An array $X$ of $n$ distinct integers is interpreted as a complete binary tree. The index of the first element of the array is $0$. If only the root node does not satisfy...
48 48 votes
7 answers 7 answers
17.7k
17.7k views
Ishrat Jahan asked Oct 31, 2014
17,655 views
Let $L$ be a context-free language and $M$ a regular language. Then the language $L ∩ M$ isalways regularnever regularalways a deterministic context-free languagealways a...
40 40 votes
1 answers 1 answer
12.3k
12.3k views
Ishrat Jahan asked Oct 31, 2014
12,335 views
Which of the following statements about regular languages is NOT true ?Every language has a regular supersetEvery language has a regular subsetEvery subset of a regular l...
4 4 votes
2 answers 2 answers
4.5k
4.5k views
Ishrat Jahan asked Oct 31, 2014
4,484 views
The cyclomatic complexity of the flow graph of a program providesan upper bound for the number of tests that must be conducted to ensure that all statements have been exe...