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 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

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions

Question

1. Let a, b R, a Answered: 1 week ago

Answered: 1 week ago