Exercise 6.1-6

Is the array with values \(\{23, 17, 14, 6, 13, 10, 1, 5, 7, 12\}\) a max-heap?

6.1-6 Heap

No. The \(7\) node is greater than its parent.

The following LaTeX code was used to generate the above heap:

\documentclass[border = 5pt, tikz]{standalone}

\begin{document}
\begin{tikzpicture}[
  every node/.style = {minimum width = 2em, draw, circle},
  level/.style = {sibling distance = 50mm/#1}
  ]
  \node {23}
  child {node {17} 
        child {node {6}
              child {node {5}}
              child {node {7}}}
        child {node {13}
              child {node {12}}
              child {edge from parent[draw = none]}}
        }
  child {node {14}
        child {node {10}}
        child {node {1}}
        };
\end{tikzpicture}
\end{document}