Data Structure II

Homework #3
CS 351.001
Spring 2024
Data Structure II
50 Points
Due: 03/28/2024, 11:59 PM
Read the instructions carefully. Points will be deducted if programs
are not written based on the instructions.

  1. Write a program in Java to implement the max-priority queue using the max-heap
    data structure. Implement the max-heap data structure using an integer array of 5
    cells. (Do not use Java built-in PriorityQueue class.) [In a max-heap, the root
    node and the intermediate node values are always greater than their children.] First,
    insert 5 integer values from the user in the max-priority queue. Then print the
    elements of the queue. After that, delete two elements from the queue and print
    them. You can implement the Priority Queue pseudo code discussed by me in class,
    which is available on Western Online. The sample inputs/ outputs are given below:
    (25 Points)
    Sample inputs and outputs:
    (User’s inputs are shown in bold)
    Enter 5 values: 5 15 7 9 20
    The elements of the max-priority queue: 20 15 7 5 9
    The element removed after the first deletion: 20
    The element removed after the second deletion: 15
  2. Write a program in Java to implement a hash table of size 11 using the hash function
    h(x) = (3x + 5) mod 11, where x is an integer element that represents the
    key. Insert the key elements only in the hash table (do not consider any value
    associated with the key). In the next phase, implement the linear probing to handle
    collision. Your program should print the hash table after inserting each element
    and ask whether the user wants to continue. (25 Points)
    Upload the two .java files on the Western Online Homework 3 page.
Click here to order similar paper @Udessaywriters.com.100% Original.Written from scratch by professional writers.

You May Also Like

About the Author: admin