Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write this program in C++ 1. Write a program that will sort an input string (letter by letter) in ascending and descending order. The program

Write this program in C++

1. Write a program that will sort an input string (letter by letter) in ascending and descending order. The program will contain functions for the Bubble Sort and the Selection Sort that are able to process string types. The bubble sort will return the string sorted in ascending order (a -z) and the selection sort will return the string sorted in descending order (z - a). The main program should prompt the user to input a string of characters of any length and then pass the string to the functions for sorting. Count the number of comparisons used by each sort. Print the sorted strings and comparison counts to the screen. Remember that you can use the bracket notation with a string to get individual characters or you can use the at function.

Example: Suppose you enter the string: The game was very tense. The sorted strings will be:

ascending: aeeeeeghmnrssttvwy (T converted to lowercase t) descending: ywvttssrnmhgeeeeea

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_2

Step: 3

blur-text-image_3

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

Objects And Databases International Symposium Sophia Antipolis France June 13 2000 Revised Papers Lncs 1944

Authors: Klaus R. Dittrich ,Giovanna Guerrini ,Isabella Merlo ,Marta Oliva ,M. Elena Rodriguez

2001st Edition

3540416641, 978-3540416647

More Books

Students also viewed these Databases questions

Question

The nature and importance of the global marketplace.

Answered: 1 week ago