[Solved] CSCI203 Lab2-Implementing a Heap

$25

File Name: CSCI203_Lab2-Implementing_a_Heap.zip
File Size: 301.44 KB

SKU: [Solved] CSCI203 Lab2-Implementing a Heap Category: Tag:
5/5 - (1 vote)

For this exercise you are to implement a heap, using an array as shown in the lectures. The heap will be built by repeatedly reading the values in the file into sequential locations in the array and then converting the array into a heap using makeheap() as seen in lectures.

Once you have built the heap you are to print out the first five elements of the heap array. Your heap should be able to hold 100 integers. A pseudocode outline for the program is given below:

Begin main display a prompt for the file name read in the file name try to open the file if the file fails to open

print an error message on the screen and exit fi

while we can read an int from the file

insert the int into the array

elihw

close the file makeheap()

for i = 1 to 5

print the ith element of the heap rof

End main

Do not implement the heap using a class or with STL. The heap must be implemented using a fixed size array of integers (100 entries should be enough). The heap array and the index to the last item in the heap should be global variables.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CSCI203 Lab2-Implementing a Heap
$25