complete the following in c++ programming code and answer question 3. use question 2 below as reference
![2. If your nameArray 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 [JOINPDOE==> [O N P D O E [J N] P D O E ==> 0 [NJ] P D O E Note: O and J were swapped Note: N and J were swapped ONJ P D OEONJ D P OE 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 [PE] ==> O N J D O [EP] Note: E and P were swapped Pass-2: [O N] J DOPE==> [O NI J DOEP O [NJ] D O P E ==> 0 [J N] D O E P Note: No Swap Note: J and N were swapped ...(so on, until the array is completely sorted) How many passes were required? How many iterations within each pass? How many swaps were performed? HOW STEPS OF BUBBLE SORT APPLIED ON YOUR NAME ARRAY SHOWN IT ANSWER 3. Repeat the same process with nameArray and this time show the stages when Selection Sort Algorithm is used. How many iterations were required? N YOUR NAME 2. ANSWER THE QUESTION](http://img.homeworklib.com/questions/babac950-c9a1-11eb-b637-b30ecf8374f6.png?x-oss-process=image/resize,w_560)
Pass 1: Move smallest character in [0,6] to first place, which is D
JONPDOE ==> DJONPOE Note: D is moved to the first place
Pass 2: Move smallest character in [1,6] to second place, which is E
DJONPOE ==> DEJONPO Note: E is moved to the second place
Pass 3: Move smallest character in [2,6] to third place, which is J
DEJONPO ==> DEJONPO Note: J is already at the correct place
Pass 4: Move smallest character in [3,6] to fourth place, which is N
DEJONPO ==> DEJNOPO Note: N is moved to the fourth place
Pass 5: Move smallest character in [4,6] to fifth place, which is N
DEJNOPO ==> DEJNOPO Note: O is already at the correct place
Pass 6: Move smallest character in [5,6] to sixth place, which is O
DEJNOPO ==> DEJNOOP Note: last O is moved to 6th place
The algorith in O(n2) as there are two nested loops. At each iteration, smallest element is selected from remaining array.
Number of steps: 6
complete the following in c++ programming code and answer question 3. use question 2 below as...
Please write a c++ code If your nameArray 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 completely sorted (alphabetically, in descending order). Show all these stages (Passes and swaps within Passes) for your nameArray. Here is an example, with the name JONPDOE, of how I want you to write these steps: Pass-1: [J O] N P D O E ==> [O J] N...
Write in C++ (Bubble Sort) implement the bubble sort algorithm - another simple yet inefficient sorting technique. its called bubble sort or sinking sort because smaller values gradually "bubble" their way to the top of the array like air bubbles rising in water, while the larger values sink to the bottom of the array. the technique uses nested loops to make several passes through the array. each pass compares successive pairs of elements. if a pair is in increasing order,...
C++ programming please Write a program that will display random numbers in order from low to high. 1. Declare an integer array of size 100. Ask the user how many numbers to work with (n). It can be less than 100. 2. Generate random numbers from 10 to 50. 3. Write the random numbers to an output file named random.dat. Close the file. 4. Open random.dat for input and read the data values into your array. Pass your array to...
Programming language: Java
Home Work No.2 due 09.11.2019 either ascending or descending SORTING: An array is said to be ordered if its values order. In an ascending ordered array, the value of each element is less than or equal to the value of the next element. That is, [each element] <= [next element]. A sort is an algorithm for ordering an array. Of the many different techniques for sorting an array we discuss the bubble sort It requires the swapping...
in c++
corresponding to the BEST answer Questions ( (2) use the linked list below, with pointer orhemcation For ench qnestion, ehonse the tete (1) What is the value of p->getNexto-getitemO? a)2 b)4 c)6 d) 8 e 10 (2) What is the value of headPtr-getNextO>get a)2 b)4 c) 6 d) 8 ) 10 Nexto>-gettemo? (3) In this version of bubble sort using an array of integers named a: for (int i o; i < ni i+) i for (int j...
I need the report like this (idea) *Sorting Algorithms: A sorting algorithm is an algorithm that puts elements of a list in a certain order. The most-used orders are numerical order and lexicographical order. Efficient sorting is important for optimizing the use of other algorithms (such as search and merge algorithms) which require input data to be in sorted lists; it is also often useful for canonical zing data and for producing human-readable output. More formally, the output must satisfy...
Write a complete C++ program that analyzes the following sorts by keeping track of how long they take to sort arrays of longS of size 5000, 10000, and 100000, as well as the number of swaps and comparisons they take in doing so: Insertion sort Selection sort Quick sort shell sort(using gaps of n/2, n/4, n/8, ..., 1) for 20, the gaps would be 10, 5, 2, and 1 shell sort(using gaps based on 2^k + 1, but starting at...
Hello I need help with this program. Should programmed in C!
Program 2: Sorting with Pointers Sometimes we're given an array of data that we need to be able to view in sorted order while leaving the original order unchanged. In such cases we could sort the data set, but then we would lose the information contained in the original order. We need a better solution. One solution might be to create a duplicate of the data set, perhaps make...
the question from the course COMP 4040 that Analysis of
Algorithms
if you want to answer it by code please use C or C++
5. Algorithm Design (20 points) Input: array A contains n distinct numbers from 1 to n, in arbitrary order. Output: number of inversions (defined as the number of pair(i, j) of array indices with i < j and A[i] > Aj]) (a) (5 points) What array with elements from the set {1, 2, ..., n) has...
Date: December 12th, 2019 4. Describe why you selected the worstcase runtime above. Recall what we said about inversions and how the number of inversions is equivalent to the number of swaps for insertion sort. Also, recall the visualization from the notes on insertion First Name: Last Name: Hint: Given a list L = {4, 15, 104, Z. 11.2.14) where we are determining the number of inversions for 10, the inversions are underlined in red. I. INSERTION SORT 1. Given...