Discrete Mathematics

posted by .

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?

  • Discrete Mathematics -

    Number of comparisons for 6 numbers:

    You need all 15 comparisons unless you modify the algorithm to keep track of exchanges.

    There are 4 exchanges in this particular example.

  • Discrete Mathematics -

    Thanks for explaining this to me!

  • Discrete Mathematics :) -

    You're welcome!

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. 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 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, …
  3. 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?
  4. 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 …
  5. 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 …
  6. 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.
  7. math 3 grader

    Sort these numbers describe your sort rule 5, 10, 16, 19, 24, 37, 40
  8. 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.
  9. math

    Sort these numbers. Describe your sort rule. 5 10 16 19 24 37 40
  10. 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[][]

More Similar Questions