CS 223 In-lab 1
Week of 1/23

For CS 223, in-labs will consist of a mix of exercises and problems and short programming assignments.  These will be due at the end of the lab period.  You may occasionally be assigned homework problems as well.  Homework will always be due at the beginning of the next lab.

Exercises

  1. Exercise 6.1-6, CLRS page 130
  2. Exercise 6.2-1, CLRS page 132
  3. Exercise 6.4-1, CLRS page 136

Programming Assignment

Write a short Java program that implements the MAX-HEAPIFY procedure given on page 130 of CLRS.  Your program should prompt the user to input 15 integers.  Store these values in order in an int[] array, then call MAX-HEAPIFY on the root of the heap.  Print out the array upon completion. 

Print out your source code and test runs on the following sequences:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15

12 14 9 5 8 6 2 11 1 4 13 15 3 10 7

Turn in exercises and print-outs to the TA.