Discrete Mathematics
posted by Joy .
Use Bubble Sort to sort the list:
7, 12, 5, 22, 13, 32
What is the maximum number of comparisons required for a list of 6 numbers?
How many vcomparisons did I actually need?

Number of comparisons for 6 numbers:
5+4+3+2+1=15
You need all 15 comparisons unless you modify the algorithm to keep track of exchanges.
There are 4 exchanges in this particular example. 
Thanks for explaining this to me!

You're welcome!
Respond to this Question
Similar Questions

java programming
You need to provide more than a yes or no answer for this question. Consider both the selection sort and the bubble sort. If these algorithms will work with duplicates explain why they will still work. If they will not work, explain … 
JAVA PROGRAM SELECTION SORT USING RECURSION
JAVA PROGRAM Details: I'm having a trouble with the print lines, i'm not sure where to start but i think I got the rest down correctly. Please if there is a mistake in this program, let me know or correct my current program below, … 
Math
In the list of numbers 1,2,3,4,5,6,7,8,9, how many of the numbers in the list are exactly 2 more than some other number in the list? 
Programming
2. Then it should prompt the user for the input file name of the file containing the data to sort. 3. If the program can't open the file or if no file name is entered (^d or ^z is entered for EOF), it should print an error message … 
Simple Array Process
need help with this generate only the pseudocode. No charting is required, but you will have to incorporate the bubble sort algorithm to ensure the selling prices are in order so you can determine the median selling price. Do not assume … 
CIS/Visual Logic
Design an application that accepts 10 numbers and displays them in descending order. Us an array to store the numbers and Bubble Sort to sort the numbers. 
math 3 grader
Sort these numbers describe your sort rule 5, 10, 16, 19, 24, 37, 40 
Discrete Mathematics
Sort with Insertion Sort and Selection Sort algorithms the following list: 329, 364, 373, 334, 320 Give the intermediate lists at each step. 
math
Sort these numbers. Describe your sort rule. 5 10 16 19 24 37 40 
discrete math
A bubble sort begins with the array: 372418 Work through the lists obtained at each step of the bubble sort. Complete the table below for the intermediate step where 7 is at position four in the array. [][][]7[][]