CS301 Assignment No. 03
SEMESTER Spring 2018
Instructions
Please read the following instructions carefully before solving & submitting assignment:
It should be clear that your assignment will not get any credit (marks) if:
Ø The assignment is submitted after due date.
Ø The submitted assignment file is not in .cpp format.
Ø The submitted assignment file does not open or corrupted.
Ø The assignment is copied (from other student or ditto copy from handouts or internet).
Uploading instructions
Ø Do not wait for grace day. Grace Day is given only if there is problem with LMS on due date. Submit your solution within due date.
Ø Note that no assignment will be accepted through email if there is any problem in LMS on grace day.
Objective
The objective of this assignment is
o To make you familiar with working and implementation of heap data structure.
Question: Marks 20 Write C++ programto implement min heap. Your program should fulfill requirements given below in points a) and b).
Data: 18, 31, 82, 85, 37, 20, 23, 79, 47, 51, 96, 97, 42, 94, 57, 29
a) Consider the data given above and build min heap of odd nodes/values only using insert method you learned in handouts/video lectures.
-
b) Consider the data given above and build min heap of all nodes/values in data using buildHeap method given in handouts/video lectures.
Assignment solution instructions:
· Graphical representation of odd min heap using insert() method and min using buildHeap() method is given below for your understanding.
· Given data should be used for input to heap in the form of array.
· For Odd min heap construction use data given above while constructing min heap, check if the number/node is odd then use it for heap construction. In case of even discard it and move to next number.