Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider arranging 'n' alphabet stored in an array A, by first finding the biggest alphabet of A and exchanging it with the element in


Consider arranging 'n' alphabet stored in an array A, by first finding the biggest alphabet of A and exchanging it with the element in A[n]. Then find the second biggest alphabet of A and exchange it with A[n-1] continue in this manner up to A[2] alphabets. For example, if A="DCBA" then after the first iteration A="ACBD" then find the next biggest alphabet and swap it. In the end the algorithm should return the output as "ABCD". Based on the approach described above, write an algorithm for arranging the given 'n' alphabets in an increasing order of the alphabets and prove the correctness of the algorithm. (7 Marks) Compute the best-case running time, worst-case running time and the average-case running time of the algorithm. Compare this algorithm with that of the insertion-sort algorithm, based on the respective T (n). Based on your analysis, conclude which algorithm performs better for which type of inputs. (3 Marks)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Business Math

Authors: Cheryl Cleaves, Margie Hobbs, Jeffrey Noble

10th edition

133011208, 978-0321924308, 321924304, 978-0133011203

More Books

Students also viewed these Programming questions