Question

List the worst case and average case Big O for each algorithm below and describe how...

List the worst case and average case Big O for each algorithm below and describe how the algorithm works. You can diagram or write a short paragraph.

  • Bubble Sort
  • Modified Bubble Sort
  • Insertion Sort
  • Merge Sort
  • Selection Sort
  • Shell
  • Heap
  • Quick
0 0
Add a comment Improve this question Transcribed image text
Answer #1

BUBBLE SORT: is a sorting algorithm that iterates through the list and compares all adjacent elements. If the adjacent element is greater it swaps the element and keeps iterating untill the list is sorted. The Average and worst case is : O(n​​​​​​2​​​).

Modified Bubble Sort: Bubble sort compares all the adjacent elements in a list which increases the time complexity. Hence we use modified bubble sort in which we have a flag that is set when an exchange is made after an entire pass over the list.

Insertion Sort: it sorts a given list of array by comparing one element at a time. It is like how we sort a list of card in our hand. We iterate through the list, leaving the sorted list behind. At every position we check the particular element with the sorted list left behind. If the element is larger it leaves it and moves forward. And if it is smaller than it sorts it in the sorted list and finds the perfect position for it. Average case: O(n​​​​​​2​​​) and worst case: O(n​​​​​​2​​​)

Merge Sort: it follows the divide and conquer method. Where we split the array into two halves and sort them individually. After the sorting is done we merge the two arrays and display the sorted list. Average case: O(nlogn) and worst case: O(nlogn)

Selection Sort: it is an algorithm which assumes the first element as the minimum element and compares it with the adjacent one. If it finds the adjacent is the minimum it assigns it as the minimum and keeps on traversing. After each iteration the minimum is placed in the front of the unsorted list. Average case: O(n​​​​​​2​​​) and worst case: O(n​​​​​​2​​​​​).

Shell sort: it is based on selection sort. This algorithm avoids large shifts as in selection sort. We first calculate a particular interval for which we have to compare by using Knuth's formula ( n= n * 3 +1, where n is the interval) . For example we have to sort : {12,31,44,10,51,1,21,55}. We take an interval of 4 so we will compare {12,51} , {31,1} , {44,21} , {10,55}. After the comparison the list will be, {12,1,21,10,51,31,44,55} after this we will apply insertion sort to sort this. Average case depend on the gap and worst case: O(n​​​​​​2​​​)

Heap Sort: is an improved selection sort and a comparison based algorithm. It is based on binary heap data structures. We find the maximum element and place it in the end of the list. In heap sort we divide the array into the sorted and unsorted part and keeps on putting the largest element in the sorted region. Average and worst case: O(nlogn).

Quick Sort: It uses the divide and conquer method and picks an element as the pivot element partitioning the array around the pivot element. You can pick the first or last or random or median as the pivot element. Average Case: O(nlogn) and worst case: O(n​​​​​​2​​​​​).

​​​​​​

​​

​​

Add a comment
Know the answer?
Add Answer to:
List the worst case and average case Big O for each algorithm below and describe how...
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
  • Puodace a char showing the number of moves required to solve the Towers of Hanoi puzle using t 30...

    Puodace a char showing the number of moves required to solve the Towers of Hanoi puzle using t 30. What is an execution frame? What is an activation record? What is contained in it? 31. Write a recursive Java method that computes the factorial of a number 2. Linear search may require up to comparisons while binary search will only require roughly comparisons 33. Sort sorts a list of values by repetitively putting a particular value into its final, sorted,...

  • 1. Which is the best sorting algorithm for larger arrays if all the items can not...

    1. Which is the best sorting algorithm for larger arrays if all the items can not fit in main memory? selection sort insertion sort quicksort Merge sort 2. Which sorting algorithm sorts items without comparing them? quick sort radix sort merge sort Insertion sort 3 What is the average running time for quicksort? O(n2) O(logn) O(nlogn) O(n) O(n2logn) 4. Examine the steps of the following algorithm and write the name of the algorithm described in the blank provided: Recursively divide...

  • . Shell sort is a sorting algorithm similar to insertion sort. Research shell sort and apply...

    . Shell sort is a sorting algorithm similar to insertion sort. Research shell sort and apply that to the following array. Show your work in Detail. [15 points] 45 20 50 10 80 30 60 70 40 90 2. Is Shell sort a stable sorting algorithm? Answer this with an example. [10 points] 3. Apply Merge Sort to sort the following list. Show your work in Detail. [15 Points] 45 20 50 10 80 30 60 70 40 90 4....

  • Insertion sort on small arrays in merge sort Although merge-sort runs in Θ(n log n) worst-case...

    Insertion sort on small arrays in merge sort Although merge-sort runs in Θ(n log n) worst-case time and insertion sort runs in Θ(n 2 ) worst-case time, the constant factors in insertion sort can make it faster in practice for small problem sizes on many machines. Thus, it makes sense to coarsen the leaves of the recursion by using insertion sort within merge sort when subproblems become sufficiently small. Consider a modification to merge sort in which n/k sublists of...

  • Inal Examination 17. Which of the sorting algorithms listed below has the time fastest best case...

    Inal Examination 17. Which of the sorting algorithms listed below has the time fastest best case run (a) Heap sort (b) Merge sort (c) Quick sort (d) Insertion sort 18. Which statement below is false: (a) Quick uick sort and merge sort are divide and conquer algorithte (b) Counting sort is a linear time sorting algorithm. (e) Insertion sort and quicksort have similar best case (d) Generic minimum spanning tree algorithm is 19. Counting sort and radix sort are linked...

  • What are the best, worst and average case complexities of the Merge Sort algorithm?

    What are the best, worst and average case complexities of the Merge Sort algorithm?

  • ?PLEASE READ CAREFULLY QUESTION #1 I’m doing a project which requires you to implement 4 sorting...

    ?PLEASE READ CAREFULLY QUESTION #1 I’m doing a project which requires you to implement 4 sorting algorithms. Bubble sort pair-wise, Bubble sort list-wise a.k.a selection sort, merge sort, and quick sort. These 4 sorting methods takes in an array of strings and sorts them alphabetically from a-z. I have all 4 sorting algorithms working fine, but I still need to fill out the table. There’s only one section I need help filling out. I basically need help filling out the...

  • The worst-case complexity of the Quicksort is O(n2). (a) Use the selection algorithm to modify Quicksort...

    The worst-case complexity of the Quicksort is O(n2). (a) Use the selection algorithm to modify Quicksort and reduce its worst-case complexity to O( n*log(n) ) (b) Write the recurrence equation for the modified Quicksort algorithm.

  • Can Anyone help me to answer these question regarding Algorithm in the computer science? 1) a)...

    Can Anyone help me to answer these question regarding Algorithm in the computer science? 1) a) Describe the merge helper method of Merge Sort.      b) What are real life examples of Bubble Sort, Selection Sort, and Insertion Sort?     c) What does it mean for a tree to be complete?     d) Describe the partition helper method of Quicksort.     e) What are two real life examples of a Priority Queue?    f) Draw a min heap with at...

  • For a list of length n, insertion sort makes _key comparisons, in the worst case. None...

    For a list of length n, insertion sort makes _key comparisons, in the worst case. None of these O(nlogzn) On O) O() Question 20 The time complexity of the quick sort is in the worst case and in the average case O), O) O(nlogon), O(nlogon) (12), O(nlog.) O(nlogon). 0() O(P), (n)

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