CPSC 2430-02 Programming Assignment #4 solved

$35.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

P4 exercises your understanding of Heaps (Priority Queues) and dynamic memory in
C++
Create a Heap (min or max, your choice) class containing the standard functionality of
insertion and removal. Use a dynamically-allocated array for storage of your heap,
allowing the heap to grow as needed (no reduction of size is required).
In addition, this heap allows the user to “flush” a value from the heap. In other words,
the user supplies a value and the heap removes all instances of that value automatically.
Because this is a structure with dynamic memory in C++, you must include the memory
management methods.
In your driver, test the heap by:
1) Inserting more than the default size number of values (to test insertion and
resize)
2) Removing the next value and printing it to the screen (to test remove)
3) “Flushing” a given value from the heap, then removing and printing values until
it is clear the flushed value has been removed (to test flush)
Note that you must know a value is on the heap to know if your flush method removed
it. Consequently, you must either insert one (or more) known values on the heap, or
track one (or more) of the random values.
Call your files “heap.h”, “heap.cpp” and “p4.cpp”. Submit your project by typing the
following command from the prompt in the directory where the files are located:
/home/fac/sreeder/submit/cpsc2430/p4_runme