Problem Set Answers: Heaps


  1. This is not a complete tree so it's not a heap.
    This looks like a maxheap but 202 is less than its left child so it's not a valid maxheap.
    This is a maxheap.
    This looks like a minheap but 160 is greater than its left child so it's not a valid minheap.
    This is a minheap.
  2.  

    *** End of Second Answer ***

  3.  

    *** End of Third Answer ***

  4.  

    *** End of Fourth Answer ***

  5.  

    *** End of Fifth Answer ***

  6.  

    *** End of Sixth Answer ***

  7.  9   12   16   64   25   121  49   94   75   36   225  269  144  196  81   100  135
    [0]  [1]  [2]  [3]  [4]  [5]  [6]  [7]  [8]  [9]  [10] [11] [12] [13] [14] [15] [16]
    
  8.  

    *** End of Eighth Answer ***

  9. 269  121  225  100  64   196  135  81   94   9    12   144  36   75   16   49   25
    [0]  [1]  [2]  [3]  [4]  [5]  [6]  [7]  [8]  [9]  [10] [11] [12] [13] [14] [15] [16]
    
    1. the left child of 242 is 99.
    2. The right child of 260 is 250.
    3. The left child of 150 is 120.
    4. 150 does not have a right child.
    5.  

  10. 225  121  196  100  64   144  135  81   94   9    12   25   36   75   16   49   269
    [0]  [1]  [2]  [3]  [4]  [5]  [6]  [7]  [8]  [9]  [10] [11] [12] [13] [14] [15] [16]
    
  11. 196  121  144  100  64   49   135  81   94   9    12   25   36   75   16   225  269
    [0]  [1]  [2]  [3]  [4]  [5]  [6]  [7]  [8]  [9]  [10] [11] [12] [13] [14] [15] [16]
    
  12. 144  121  135  100  64   49   75   81   94   9    12   25   36   16   196  225  269
    [0]  [1]  [2]  [3]  [4]  [5]  [6]  [7]  [8]  [9]  [10] [11] [12] [13] [14] [15] [16]
    
  13. 135  121  75   100  64   49   16   81   94   9    12   25   36   144  196  225  269
    [0]  [1]  [2]  [3]  [4]  [5]  [6]  [7]  [8]  [9]  [10] [11] [12] [13] [14] [15] [16]
    
  14. 121  100  75   94   64   49   16   81   36   9    12   25   135  144  196  225  269
    [0]  [1]  [2]  [3]  [4]  [5]  [6]  [7]  [8]  [9]  [10] [11] [12] [13] [14] [15] [16]
    
  15. 100  94   75   81   64   49   16   25   36   9    12   121  135  144  196  225  269
    [0]  [1]  [2]  [3]  [4]  [5]  [6]  [7]  [8]  [9]  [10] [11] [12] [13] [14] [15] [16]
    


Email Me | Office Hours | My Home Page | Department Home | MCC Home Page

© Copyright Emmi Schatz 2009