Question

If you were to perform a bubble sort on the following list, what would be the...

If you were to perform a bubble sort on the following list, what would be the first thing you would do? In other words, which two names would you first compare?

John
Bill
Rob
Ann
Sue
Mary

0 0
Add a comment Improve this question Transcribed image text
Answer #1

If we were to perform a bubble sort on the following list we would compare the first two names that is John Bill  because in bubble sort for every pass adjacent names are compared and swaps them if they are in wrong order.

EXAMPLE

In First pass:

John Bill Rob Ann Sue Mary (Bill is small alphabetically so these two are swapped)

Bill John Rob Ann Sue Mary

Bill John Rob Ann Sue Mary (John is less than Rob so no swapping)

Bill John Rob Ann Sue Mary (Ann <Rob)

Bill John Ann Rob Sue Mary

so like this it continues therefore John and Bill are the two names we would compare first in bubble sort

if u understand up vote else post a comment

Add a comment
Know the answer?
Add Answer to:
If you were to perform a bubble sort on the following list, what would be the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • What action do merge sort, quick sort, and heap sort perform that so radically reduces their...

    What action do merge sort, quick sort, and heap sort perform that so radically reduces their complexity? (From O(n2) for the other sorts that we looked at earlier–selection sort, bubble sort, and insertion sort–to O(n log n) for these)? Hint: they all employ a strategy that has to do with how many things they look at in a pass. Describe a situation where merge sort would be a better choice for sorting than quick sort.

  • You will create a dimple Bubble Sort program to sort a string of random integers or...

    You will create a dimple Bubble Sort program to sort a string of random integers or text. Please read instructions and examples Please show screenshot of proof that the code works in the C program ECE 216 Programming Project 2 The Bubble Sort You will create a simple Bubble Sort program to sort a string of random integers or text or whatever you can punch in from the keyboard. For the input data, you will input a string of single...

  • Write a JAVA Program: Compare the performance of bubble sort and selection sort over several arrays....

    Write a JAVA Program: Compare the performance of bubble sort and selection sort over several arrays. - Write two methods that sort arrays of doubles. One method should use selection sort, and the other should use bubble sort. - In each of the sort methods, add code that counts the total number of comparisons and total number of swaps performed while sorting the entire array (be careful; don't count each pass through the array separately) - Each time an array...

  • Consider the following python code that will sort the list of numbers using the Bubble Sort...

    Consider the following python code that will sort the list of numbers using the Bubble Sort algorithm def bubbleSort(alist): print(alist) for j in range (len(alist) - 1, 8, -1): for i in range(): if alist[i] > alist[i + 1]: temp = alist[i] alist[i] = alist[i+1] alist[i+1] = temp print(alist) alist = [52, 25, 94, 17, 25, 52] bubbleSort (alist) print(alist) Sort the following series of values into ascending order using the Bubble Sort algorithm. Write out the complete row of...

  • Use Bubble Sort to Sort the following array. Show the steps you would take. [3, 1,...

    Use Bubble Sort to Sort the following array. Show the steps you would take. [3, 1, 4, 1, 5, 9, 2, 6, 5]

  • C++ 2.3 Activity 3: Bubble Sort For this activity, you are required to provide files called...

    C++ 2.3 Activity 3: Bubble Sort For this activity, you are required to provide files called act3.cpp as well as a makefile to compile and run it. In your file, act3.cpp, should have a skeleton of a main program as per normal which you will then fill it in as per the following. The objective of this activity is to demonstrate the bubble sort algorithm for arrays. You are going to implement this as a function with the following definition:...

  • 6 6. Merge Bubble Sort: a) How does the merge bubble sort break the array into...

    6 6. Merge Bubble Sort: a) How does the merge bubble sort break the array into sublists? b) What does it need to use for each sublist and then what does it do with all of the sublists? c) What is the Big-O notation for this sort? 7. Merge Sort: a) How does the merge sort use recursion to break the array into sublists? b) What happens to each of these sublists to get the final sorted list? c) What...

  • Write a program that compares the execution speed of two different sorting algorithms: bubble sort and...

    Write a program that compares the execution speed of two different sorting algorithms: bubble sort and selection sort. It should do this via functions you must write with the following prototypes: void setRandomValues(int[], int[], int length); This function sets two integer arrays with identical random values. The first two arguments are two integer arrays of the same length, and the third argument is the length of those arrays. The function then sets each element in the first and second argument...

  • SortAndSearch.cpp – Objectives: Binary Search and Selection sort You are given a list of 20 names...

    SortAndSearch.cpp – Objectives: Binary Search and Selection sort You are given a list of 20 names as follows: {"Collins, Bill", "Smith, Bart", "Michalski, Joe", "Griffin, Jim",                         "Sanchez, Manny", "Rubin, Sarah", "Taylor, Tyrone", "Johnson, Jill",                         "Allison, Jeff", "Moreno, Juan", "Wolfe, Bill", "Whitman, Jean",                         "Moretti, Bella", "Wu, Hong", "Patel, Renee", "Harrison, Rose",                   "Smith, Cathy", "Conroy, Pat", "Kelly, Sean", "Holland, Beth"}; Write a program to sort and display the names in alphabet order (use selection sort). The program prompts...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT