Question

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 algorithms. Make sure that you check the validity of any information found in any website before using them and if used acknowledge the references properly. [25 points]

http://www.sorting-algorithms.com/

http://courses.cs.vt.edu/csonline/Algorithms/Lessons/index.html

http://www.codeproject.com/Articles/132757/Visualization-and-Comparison-of-sorting-algorithms

Java Language

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

Analysis based on the time complexity of the sorting algorithms:

1. Bubble Sort: Average and worst case complexity: O(n2), best case: O(n)
The best case when the array is already sorted and worst case when the array is reversed.

2. Selection Sort: O(n2) for worst, best and average case.

3. Merge Sort: O(N log(n)) for worst, best and average case.

4. Heap Sort: O(N log(n)) for worst, best and average case.

5. Quick Sort: O(n2) in the worst case and O(N log(n)) for average and best case.

Space complexity for different sorting algorithms:

1. Bubble Sort: O(1) does not require additional memory for sorting.

2. Selection Sort: O(1), it also does not require additional memory for sorting.

3. Merge Sort: O(n), it requires the additional memory comparable to the size of the array which needs to get sorted.

4. Heap Sort: O(1).

5. Quick Sort: O(log(n)), it requires log(n) space for the sorting.

Stability: It means that whether the array with the same values are kept in order or not if it maintains the order then the algorithm is stable otherwise not stable.

  • Bubble Sort, insertion sort and merge sort are stable techniques.
  • selection Sort, quick sort, and heapsort are unstable.

If you have any problem regarding the understanding of the solution do let me know in the comment section.
Thanks

Add a comment
Know the answer?
Add Answer to:
This question involves comparing the sorting algorithms that we studied so far such as selection sort,...
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
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