Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that calls stringSort with strings of various lengths where the characters of each string are in descending order. Include a counter in

Write a program that calls stringSort with strings of various lengths where the characters of each string are in descending order. Include a counter in your function right above the second if statement, to count the number of item comparisons for each input. Answer the questions below.

# of item comparisons for strings of length 1: 0

# of item comparisons for strings of length 2: 1

# of item comparisons for strings of length 3: 3

# of item comparisons for strings of length 4: 7

# of item comparisons for strings of length 5: 14

# of item comparisons for strings of length 6: 25

c) Find a polynomial f(n}, of lowest degree that fits your results from part b. In other words f(1) should equal the first number, f(2) should equal the second number and so on. Explain how you came up with your polynomial.

d) Based on your result from Part c, how does the efficiency of stringSort compare with other sorting algoritms like bubblesort, mergesort etc. ?




Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Entrepreneurship

Authors: Andrew Zacharakis, William D Bygrave

5th Edition

9781119563099

Students also viewed these Programming questions

Question

explain what accounting standards are and why they exist.

Answered: 1 week ago

Question

explain the nature of accounting principles and concepts;

Answered: 1 week ago