Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. If your nameArray []= {'J', 'O', 'N','P', 'D' 'O', 'E'} variable is sorted using Bubble Sort Algorithm, it will go through a several pass-throughs

1. If your nameArray []= {'J', 'O', 'N','P', 'D' 'O', 'E'} variable is sorted using Bubble Sort Algorithm, it will go through a several pass-throughs and characters will be swapped in each pass-through, until nameArray gets completed sorted (alphabetically ascending order). Show all these stages (Passes and iterations within Passes) for your nameArray. Based on our example, here is a sample of how I want you to write these steps:

Pass-1: [J O] N P D O E ==> [O J] N P D O E Note: O and J were swapped

O [J N] P D O E ==> O [N J] P D O E Note: N and J were swapped

O [J N] P D O E ==> O [N J] P D O E Note: N and J were swapped

O N [J P] D O E ==> O N [J P] D O E No Swap

O N J [P D] O E ==> O N J [D P] O E Note: D and P were swapped

O N J D [P O] E ==> O N J D [O P] E Note: O and P were swapped

O N J D O [P E] ==> O N J D O [E P] Note: E and P were swapped

Pass-2: [O N] J D O P E ==> [O N] J D O E P Note: No Swap

O [N J] D O P E ==> O [J N] D O E P Note: J and N were swapped..

(so on, until the array is completely sorted) How many passes were required? How many iterations of each pass? How many swaps were performed?

2. Repeat the same process with nameArray and this time shows the stages when Selection Sort Algorithm is used. How many iterations were required?

Note: I need C++ coding for these.

Thank you

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

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions