Answered step by step
Verified Expert Solution
Question
1 Approved Answer
For this assignment you need to implement a min - heap data structure in C + + , and use it to sort a vector
For this assignment you need to implement a minheap data structure in C and use it to sort a vector of distinct integers into ascending order. While doing so count the number of swap operations performed during insert and delete. The initial insertion during insert or replacement of the removed element during deletion do not count towards this. The input vector is to be read from standard input, in the format n value value value n Instead of just sorting the original input vector, you also need to resort vectors with elements already sorted in ascending or descending order. Afterwards, report swap counts for insertion and deletion for each of these three input vectors. For example: Here the three outputs originalascendingdescending correspond to the input vectors: Note that some sorting algorithms perform particularly poorly or well for sorted inputs eg bubble sort Running your code on some larger inputs can give you an idea whether or not or to what degree that's the case for heapsort. You can use CodeRunner to test your work, but must submit your assignment as usual. If teamwork is permitted and you work in a team, you must include the names and student IDs of all team members as comments in your submission, and each team member must submit the same assignment separately. Working Example For the original input the heap vector representing the tree is updated as follows:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started