Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Implement the following algorithm, which is given a duplicate-free array array as input, in C++. whatDoIDo (array): Problem 3 (4+2+2 marks). (a) Implement the following
Implement the following algorithm, which is given a duplicate-free array array as input, in C++. whatDoIDo (array):
Problem 3 (4+2+2 marks). (a) Implement the following algorithm, which is given a duplicate-free array array as input, in C++. whatDoIDo (array): 1) Build a heap from array (using buildHeap as explained in class). where the heap starts at position array [0] 2) Starting from j = size of array - 1, as long as j>0: i. Swap the entries array [O] and array [j] . ii. Percolate down array (0), but only within the subarray array [O..j-1). iii. Decrement j by 1. Provide three input /output examples for duplicate-free arrays of size about 10. (b) What does whatDo ID do? Explain your answer (c) What is the worst-case running time of whatDo ID0, in dependence of the size N of the given array? Explain yourStep 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