Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Alex has some pillars of different heights. He is trying to arrange the pillars in descending order according to their heights. Recently he has learned

Alex has some pillars of different heights. He is trying to arrange the pillars in descending order according to their heights. Recently he has learned Divide & Conquer (D&C) algorithm strategy. There is a sorting algorithm in Divide & Conquer whose special case is, f(n) = O(n^2). So, now you have to help Alex to sort the pillars with that particular D&C algorithm. Finally, you need to display k, the number of times the division will be required for sorting and also display the heights in descending order.


Input: At the first line, you have to take the number of pillars, N (1<=N<=100), then, in the second line, you have to take N integer numbers indicating the heights of the pillars.


Output: You need to display k and the height of the pillars in descending order



Sample Input:

6

6 3 8 11 2 77


Sample Output:

3

77 11 8 6 3 2 

Step by Step Solution

3.50 Rating (160 Votes )

There are 3 Steps involved in it

Step: 1

Hey you use Quick sort sorting algorithm to sort the pillars Quick sort algorithm has On log n in av... 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

Smith and Roberson Business Law

Authors: Richard A. Mann, Barry S. Roberts

15th Edition

1285141903, 1285141903, 9781285141909, 978-0538473637

More Books

Students also viewed these Computer Engineering questions

Question

Determine a value index for 2013 using 2000 as the baseperiod.

Answered: 1 week ago