Answered step by step
Verified Expert Solution
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:
Write the bubble sort method that:
has an input parameter specifying whether to sort from AZ or ZA an integer, Boolean, etc.
initializes a counter variable to increments the counter every time a swap is performed then outputs the counter when the sort is complete.
outputs the sorted array
Write the selection sort method that:
has an input parameter specifying whether to sort from AZ or ZA an integer, Boolean, etc.
initializes a counter variable to increments the counter every time a swap is performed then outputs the counter when the sort is complete.
outputs the sorted array
Load the names from the unsortedNames.txt into the array then
Execute the Bubble Sort method AZ note the counter.
Execute the Selection Sort method ZA on the recently sorted list, note the counter.
Reload the names from the unsortedNames.txt into the array then:
Execute the Selection Sort method AZ note the counter.
Execute the Bubble Sort method ZA note the counter.
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
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
Kenya
Victorina
Keitha
Ernestina
Kenna
Tyesha
Pasty
Venus
Naoma
Dustin
Grady
Irvin
Ruthie
Viki
Kecia
Gricelda
Vaughn
Theda
Adelaide
Lea
Hee
Katelynn
Jayson
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started