Question: Bubble SortThe simplest sorting algorithm is bubble sort. The bubble sort works by iterating down an array to be sorted from the first element to

Bubble SortThe simplest sorting algorithm is bubble sort. The bubble sort works by iterating down an array to be sorted from the first element to the last, comparing each pair of elements and switching their positions if necessary. This process is repeated as many times as necessary, until the array is sorted. Since the worst case scenario is that the array is in reverse order, and that the first element in sorted array is the last element in the starting array, the most exchanges that will be necessary is equal to the length of the array. Here is a simple example: Step-by-step exampleLet us take the array of numbers "51428", and sort the array from lowest number to greatest number using bubble sort. In each step, elements written in bold are being compared. Three passes will be required.First Pass:(51428)(15428), Here, algorithm compares the first two elements, and swaps since 5>1.(15428)(14528), Swap since 5>4(14528)(14258), Swap since 5>2(14258)(14258), Now, since these elements are already in order (8>5), algorithm does not swap them.Second Pass:(14258)(14258)(14258)(12458), Swap since 4>2(12458)(12458)(12458)(12458)Now, the array is already sorted, but our algorithm does not know if it is completed. The algorithm needs one whole pass without any swap to know it is sorted.Third Pass:(12458)(12458)(12458)(12458)(12458)(12458)(12458)(12458) Write a LabVIEW program that performs the bubble sort methodology. The input (control) should be a 1D array of any length. The output (Indicator) should be a 1D array that has been sorted. If youve completed these try adding these features (extra bonus material):1. Try sorting a 2D array using the same technique. Have the user enter in which column of the 2D array they wish to sort by and have the rows sort according to that column. Make sure all numbers in the row stay together and that you are not just sorting the singular column.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!