Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

List the unsortedNames.txt contains a list of unsorted names. Your task is to: 1 . Write the bubble sort method that: has an input parameter

List the unsortedNames.txt contains a list of unsorted names. Your task is to:
1. Write the bubble sort method that:
has an input parameter specifying whether to sort from A-Z or Z-A (an integer, Boolean, etc.)
initializes a counter variable to 0, increments the counter every time a swap is performed then outputs the counter when the sort is complete.
outputs the sorted array
2. Write the selection sort method that:
has an input parameter specifying whether to sort from A-Z or Z-A (an integer, Boolean, etc.)
initializes a counter variable to 0, increments the counter every time a swap is performed then outputs the counter when the sort is complete.
outputs the sorted array
3. Load the 100 names from the unsortedNames.txt into the array then
Execute the Bubble Sort method (A-Z), note the counter.
Execute the Selection Sort method (Z-A) on the recently sorted list, note the counter.
4. Reload the 100 names from the unsortedNames.txt into the array then:
Execute the Selection Sort method (A-Z), note the counter.
Execute the Bubble Sort method (Z-A), note the counter.
5. Referring to the counter variable which indicates the number of swaps performed by the algorithm, which algorithm is more efficient? In which case is the algorithm more efficient? Keep in mind that state of the array before executing the sorting algorithm (sorted or unsorted). Does this affect the number of swaps performed?
File unsortedNames.txt below
Tu
Benjamin
Mauro
Shavon
Phyllis
Candace
Charlotte
Tamra
Francisco
Donita
Sandy
Annamarie
Renetta
Hedy
Delphia
Cherlyn
Vania
Shellie
Valorie
Tom
Lizabeth
Bao
Prince
Nicole
Lashon
Orlando
Latonia
Dian
Clarita
Herminia Toccara
Sadye t
Kenya
Victorina
Keitha
Ernestina
Kenna
Tyesha
Pasty
Venus
Naoma
Dustin
Grady
Irvin
Ruthie
Viki
Kecia
Gricelda
Vaughn
Theda
Adelaide
Lea
Hee
Katelynn
Jayson
Ty
Wilfredo
Heriberto
Neely Alethea
Ethel
Debora
Marcelene
Sharan t
Demarcus
Barbar
Brigida
Joet.ta
Xavier
Letty
Shani
Delscie
Kerstin
Leila
Shea
Marsha
Reginald
Franklin
Nathan
Rhona
Darwin
Sebastian
Angila
Laurine
Chase
Eula
Stephany
Anthony

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

Fundamentals Of Database Management Systems

Authors: Mark L. Gillenson

3rd Edition

978-1119907466

More Books

Students also viewed these Databases questions