\documentclass[11pt]{article}

\setlength{\topmargin}{-.8in}  
\setlength{\oddsidemargin}{0in}
\setlength{\evensidemargin}{0in}
\setlength{\textwidth}{6.5in}
\setlength{\textheight}{9.5in}


\begin{document}

\title{Class work: Heaps}

\date{}
\maketitle

\begin{enumerate}

\item {(CLRS 6.1-1)}  What are the minimum and maximum number of elements in a heap of
  height $h$? Note: the height of a heap is the number of edges on the
  longest root-to-leaf path.  

\item {(CLRS 6.1-2)} Show that an n-element heap has height $\Theta(\lg
  n)$  (more precisely, $\lceil \lg n \rceil$). 

\item {(CLRS 6.1-3)} Where in a min-heap might the largest element reside, assuming
  that all elements are distinct?

\item {(CLRS 6.1-5)} Is an array that is in sorted order a min-heap?  


\item {(CLRS 6.1-7)}  Show that the leaves are the  nodes indexed by
  $\lfloor n/2 \rfloor + 1, ... , \lfloor n/2 \rfloor + 2, ... , n$. 

\item What is the effect of calling HEAPIFY$(A,i)$ for $i >
  size[A]/2$? (Sometimes called HEAPIFY is called DOWN-HEAPIFY,
  because it heapifies down). Here $i$ is the index of the node where
  HEAPIFY is called; initially $i=1$ (the root).


\item {(CLRS 6.5-2)} Illustrate the operation of HEAP-INSERT (A, 7)
  on the heap (note: this is a min-heap):
$$ A = \{
2, 5,10, 6, 8, 100, 11, 9, 15, 9, 10, 200, 101 \}$$


\item {(CLRS 6.5-3)} Write pseudocode for the procedure HEAP-INSERT
  and HEAP-DELETE on a min-heap.

\item {(CLRS 6.2-1)} Illustrate the operation of HEAPIFY(A) on $$A =
  \{(20, 5,10, 6, 8, 100, 11, 9, 15, 9, 10, 200, 101, 12 \}$$ (note:
  (Sometimes called HEAPIFY is called DOWN-HEAPIFY, because it
  heapifies down.)


\item {(CLRS 6.3-1)} Illustrate the operation of BUILD-MAX-HEAP on the array
  $$A = \{ 5, 3, 17, 10, 84, 19, 6, 22, 9\}$$


%\item  List the differences between a binary search tree and a heap
%  (what operations does each structure support)


\item {(CLRS 6.4-1)} Illustrate the operation of Heapsort on the array $$ A =
  \{ 5, 13, 2, 25, 7, 17, 20, 8, 4\}$$

\item {(GT C-2.31)} Develop an algorithm that computes the $k$th smallest
  element in a set of $n$ distinct integers in $O(n + k \lg n)$
  time.


\item {(CLRS 6.4-3)} What is the running time of Heapsort on an array of length n
  that is already sorted in increasing order?  What about decreasing
  order? 


\end{enumerate}



\end{document}
%%% Local Variables: 
%%% mode: latex
%%% TeX-master: t
%%% End: 
