Question

Differentiate between Selection Sort and Bubble Sort algorithms. Explain your answer by providing Best, Average, and...

Differentiate between Selection Sort and Bubble Sort algorithms. Explain your answer by providing Best, Average, and Worst Case scenarios.

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

Selection Sort

Scan all items and find the smallest. Swap it into position as the first item. Repeat the selection sort on the remaining N-1 items.

I found this the most intuitive and easiest to implement — you always iterate forward (i from 0 to N-1), and swap with the smallest element (always i). Time complexity in all cases best, average and worst is O(n2) and space complexity is O(1).

Bubble Sort

Starting on the left, compare adjacent items and keep “bubbling” the larger one to the right (it’s in its final place). Bubble sort the remaining N -1 items.

Though “simple” I found bubble sort nontrivial. In general, sorts where you iterate backwards (decreasing some index) were counter-intuitive for me. With bubble-sort, either you bubble items “forward” (left-to-right) and move the endpoint backwards (decreasing), or bubble items “backward” (right-to-left) and increase the left endpoint. Either way, some index is decreasing.
You also need to keep track of the next-to-last endpoint, so you don’t swap with a non-existent item.

Time complexity in all best case is O(n), and average and worst is O(n2) and space complexity is O(1).

Add a comment
Know the answer?
Add Answer to:
Differentiate between Selection Sort and Bubble Sort algorithms. Explain your answer by providing Best, Average, and...
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
  • This program should test the running time of these algorithms: Selection Sort Insertion Sort Bubble Sort...

    This program should test the running time of these algorithms: Selection Sort Insertion Sort Bubble Sort Merge Sort Quick Sort Heap Sort You have access to the implementation of all of these sorting algorithms, and you may use what is provided in your text directly. Be sure to cite the source of these implementations in the header of your program. Please maintain the property that these sorting algorithms sort arrays in ascending order. For this homework, you will write a...

  • This question involves comparing the sorting algorithms that we studied so far such as selection sort,...

    This question involves comparing the sorting algorithms that we studied so far such as selection sort, bubble sort, insertion sort, merge sort & quicksort. First briefly explain the idea behind each of them. And then compare them according to the criterion such as time (best, worst and average case) and space efficiency, stability, applicability (when performs best) etc. You may use following links as hints, however you will be able to find a significant number of links that compare sorting...

  • 8 Sorting Algorithms: Bubble, selection, insertion, quick, merge, bucket, radix, counting. 1. A..Which of the above...

    8 Sorting Algorithms: Bubble, selection, insertion, quick, merge, bucket, radix, counting. 1. A..Which of the above sorting algorithms does TimSort use? 2. Which of the above algorithms sort a REVERSE ORDER list in O(n2 ) (worst case)? 3. Which of the above algorithms sort a REVERSE ORDER list in O(nlogn) (worst case)? 4. Which of the above algorithms sort an ordered list , a reverse ordered list, and a random list (all three) in 0(nlogn) (worst case)? 5. Which of...

  • Please type, no handwriting!!! In case i cant see clear... 4. (5 Points) Describe best case,...

    Please type, no handwriting!!! In case i cant see clear... 4. (5 Points) Describe best case, average case, and worst case in terms of Big O Notation. When implementing algorithms or data structures which two “Big O cases” are most important to consider and why? 5. (10 points) Bubble Sort and Selection Sort explain the similarities and difference between the two algorithms. What is the Worst Case Big (O) and why?

  • Sort the following lists with bubble sort and insertion sort algorithms. Show your steps. 10,11,5,3,15,17,1,2,20,21,4

    Sort the following lists with bubble sort and insertion sort algorithms. Show your steps. 10,11,5,3,15,17,1,2,20,21,4

  • Please explain in detail Compare the efficiency of the Merge Sort and Selection Sort algorithms.

    Please explain in detail Compare the efficiency of the Merge Sort and Selection Sort algorithms.

  • How to compute/prove average case complexity for sorting algorithms? I have to compute the best case,...

    How to compute/prove average case complexity for sorting algorithms? I have to compute the best case, worst case and average case time complexity for various sorting algorithms. I am ok with identifying the basic operations and proving the number of basic operations for best and worst case. However, I am at a loss of how to compute/prove the average case for these sorting algorithms. For example I can find in sources that the average case of say Shaker Sort and...

  • Possible to guessing the Algorithms bubble sort, quick sort, selection sort, shell sort? List A: 0,...

    Possible to guessing the Algorithms bubble sort, quick sort, selection sort, shell sort? List A: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 Alg. 1                    1 moves, 10 comparisons Alg. 2                    68 moves, 19 comparisons Alg. 3                    0 move, 15 comparisons Alg. 4                    9 moves, 63 comparisons Alg. 5                    0 move, 45 comparisons               List B: 9, 8, 7, 6, 5, 4, 3, 2, 1, 0 Alg. 1                    144 moves, 90 comparisons Alg. 2                    68 moves, 15 comparisons Alg....

  • 2. Suggest a structured plan (algorithm) for the bubble sort and selection sort, and perform running...

    2. Suggest a structured plan (algorithm) for the bubble sort and selection sort, and perform running time analysis for both best and worst case. 3. Consider the age data of 12 children who are supposed to undergo for vaccination in ascending order of their age. Suggest and apply a sorting technique which can efficiently handle this data. Show all the intermediate steps clearly. Child ID 01 02 03 04 05 06 07 08 09 10 11 12 2. Age 1...

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