Question: Q 5 ) ( 2 5 pts ) Come up with a set of 1 0 numbers between 1 and 1 0 0 , let's
Qpts Come up with a set of numbers between and let's store these numbers in an array called A provide a trace of the call to MaxHeapify A Make sure the set of numbers you chose results in at least mathbf swaps.
Assume you are given a sequence consisting of three types of n fruits: Apples, oranges, and bananas. The fruits are all mixed in the sequence and we want to order them such that all the apples are at the beginning of the sequence, followed by all the oranges, which are then followed by all the bananas. This arrangement must be done inplace, that is you are only allowed to use constant space other than the input sequence containing the fruits. You are allowed to access a fruit at any index i and inspect its type, but you can only do this once. You are also allowed to swap two fruits at any pair of indices ij Each of these operations cost O time.
a Design an algorithm to do the desired arrangement in On time. b Argue why your algorithm has the given bound.
Use only two pointers
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
