/Heap

Primary LanguageJava

Max Heap

This program will create a max heap in two ways:

  • Series of Insertions - It will reheap the max heap after each node is added.
  • Optimal Method - It will reheap after all the nodes have been added to the max heap.

  • The user can test this program with:

  • 20 sets of 100 randomly generated integers
  • Fixed integer values from 1 to 100

  • Sample Output

    
    ==========================================================================
    
    Please select how to test the program:
    (1) 20 sets of 100 randomly generated integers
    (2) Fixed integer values 1-100
    (3) Exit
    Enter choice: 1
    
    Average number of swaps for series of insertions: 107
    Average swaps for optimal method: 45
    
    ==========================================================================
    
    Please select how to test the program:
    (1) 20 sets of 100 randomly generated integers
    (2) Fixed integer values 1-100
    (3) Exit
    Enter choice: 2
    
    Heap built using a series of insertions: 100,94,99,77,93,98,61,68,76,84,...
    Number of swaps: 480
    Heap after 10 removals: 90,89,62,77,88,53,61,68,76,84,...
    
    Heap built using optimal method: 100,95,99,79,94,98,63,71,78,87,...
    Number of swaps: 96
    Heap after 10 removals: 90,89,63,79,88,55,62,71,78,87,...
    
    ==========================================================================
    
    Please select how to test the program:
    (1) 20 sets of 100 randomly generated integers
    (2) Fixed integer values 1-100
    (3) Exit
    Enter choice: 3
    
    Thanks for using my program!