Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

********* I have completed most of the program, however I cannot get the read from HEAPinput.txt to work. I really only need to know how

image text in transcribed

image text in transcribed

image text in transcribed

*********

I have completed most of the program, however I cannot get the read from HEAPinput.txt to work. I really only need to know how to read from the text file and create a heap by using the buildHeap() function.

*********

This is a programming project, to be completed and graded on general.asu.edu, a Linux machine You will perform modular design, provide a Makefile to compile various modules to generate the executable file named run. You need to have a module that provide the services including command line interpretation. You need to have a module that implement the min-heap data structure You should use the C+ programming language, not any other programming language. Also your program should be based on the g++ compiler on general.asu.edu. All programs will be compiled and graded on general.asu.edu, a Linux based machine. You will need to submit it electronically on Canvas, in one zip file, named CSE310-P01-Lname-Fname, where Lname is your last name and Fname is your first name. The zip file should contain a set of files that are absolutely necessary to compile and execute your program. If your program does not compile and work on general.asu.edu, vou will receive 0 on this proiect. You need to define the following data types o ELEMENT is a data type that contains a field named key, which is of type int. Note that ELEMENT should not be of type int. HEAP is a data type that contains three fields named capacity (of type int), size (of type int), and H (an array of type ELEMENT with index ranging from 0 to capacity The functions that you are required to implement are: Initialize(n) which returns an object of type HEAP with capacity n and size 0. This function requires you to perform dynamic memory allocation, given the demand. BuildHeap(heap, A, n), where heap is a HEAP object. A is an array of type ELEMENT, and n is the size of array A. This function copies the elements in A into heap->H (starting from H[1] and uses the linear time build heap algorithm to obtain a min-heap of size n from the given array A Insert(heap, flag, k) which inserts an element with key equal to k into the min-heap heap When flag-1, the function does not do any additional printing. When flag-2, the function prints out the heap content before the insertion, and the heap content after the insertion . DeleteMin(heap, flag) which deletes the element with minimum key and returns it to the caller When flag-1, the function does not do any additional printing. When flag-2, the function prints out the heap content before the deletion, and the heap content after the deletion DecreaseKey(heap, flag, index, value) which decreases the key field of the heap element pointed to by index to value, which should not be larger than the current value. Note that you have to make necessary adjustment to make sure that heap order is maintained. When flag-1, the function does not do any additional printing. When flag-2, the function prints out the heap content before the decrease key operation, and the heap content after the decrease key operatioin . printHeap(heap) which prints out the heap information, including capacity, size, and the key fields of the elements in the array with index going from 1 to sizH (starting from H[1] and uses the linear time build heap algorithm to obtain a min-heap of size n from the given array A Insert(heap, flag, k) which inserts an element with key equal to k into the min-heap heap When flag-1, the function does not do any additional printing. When flag-2, the function prints out the heap content before the insertion, and the heap content after the insertion . DeleteMin(heap, flag) which deletes the element with minimum key and returns it to the caller When flag-1, the function does not do any additional printing. When flag-2, the function prints out the heap content before the deletion, and the heap content after the deletion DecreaseKey(heap, flag, index, value) which decreases the key field of the heap element pointed to by index to value, which should not be larger than the current value. Note that you have to make necessary adjustment to make sure that heap order is maintained. When flag-1, the function does not do any additional printing. When flag-2, the function prints out the heap content before the decrease key operation, and the heap content after the decrease key operatioin . printHeap(heap) which prints out the heap information, including capacity, size, and the key fields of the elements in the array with index going from 1 to siz

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Create a Fishbone diagram with the problem being coal "mine safety

Answered: 1 week ago