×

### Let's log you in.

or

Don't have a StudySoup account? Create one here!

×

### Create a StudySoup account

#### Be part of our community, it's free to join!

or

##### By creating an account you agree to StudySoup's terms and conditions and privacy policy

Already have a StudySoup account? Login here

by: logeybearrr

151

0

3

# CS130A: Sorting Algorithm Analyses

Marketplace > University of California Santa Barbara > ComputerScienence > CS130A Sorting Algorithm Analyses
logeybearrr
UCSB
GPA 3.75

Koc

These notes were just uploaded, and will be ready to view shortly.

Purchase these notes here, or revisit this page.

Either way, we'll remind you when they're ready :)

Get a free preview of these Notes, just enter your email below.

×
Unlock Preview

### Preview these materials now for free

Why put in your email? Get access to more of this material and other relevant free materials for your school

Detailed analyses and comparisons between Bubble Sort, Insertion Sort, Merge Sort and Quicksort. Includes plots comparing all four sorting algorithms and their time complexities for several input p...
COURSE
PROF.
Koc
TYPE
Test Prep (MCAT, SAT...)
PAGES
3
WORDS
CONCEPTS
Computer Science, CS, CMPSC
KARMA
75 ?

## Popular in ComputerScienence

This 3 page Test Prep (MCAT, SAT...) was uploaded by logeybearrr on Tuesday June 10, 2014. The Test Prep (MCAT, SAT...) belongs to a course at University of California Santa Barbara taught by a professor in Fall. Since its upload, it has received 151 views.

×

## Reviews for CS130A: Sorting Algorithm Analyses

×

×

### What is Karma?

#### You can buy or earn more Karma at anytime and redeem it for class notes, study guides, flashcards, and more!

Date Created: 06/10/14
Logan Ortega 1 CMPSC 130A PA4 Bubble Sort Insertion Sort Quicksort amp Merge Sort Profiling ABSTRACT Upon profiling the implementation of Bubble Sort Insertion Sort Quicksort and Merge Sort algorithms the evidence clearly provides a ranking based on time complexity The basis of this report will be the comparison of runtimes for the four sorting algorithms with various sample patterns ordered increasingly ordered decreasingly and no order The following content of this report will consist of multiple graphs illustrating the relationship between the above sorting algorithms as well as a brief description and analysis of the graphs and their significance Note the xaxis represents the sample size in increments of one thousand element while the yaxis shows the relative time complexities Additionally it should be emphasized that the yaxis is time complexity and not processing time The range for processing time would be far too large to visualize the relationships between the sorting algorithms on a graph so select sorting algorithms were proportionally scaled down to fit on the graph with the remaining sorting algorithms For example for the increasingly ordered case the processing time of the Bubble Sort was divided by 1000 to match the range of the other sorting algorithms Since this report is focused on the time complexities of the sorting algorithms and not their processing times this is rather trivial and will not be discussed for the remainder of this report CASE 1 ORDERED INCREASINGLY ncea5g5et The first case of observance comes from comparing the four sorting algorithms when sorting a set already increasingly ordered 8 Graph 1 illustrates the relationship between each sorting algorithm and its time 0 complexity when sorting a set of this pattern h Bubble Sort runs in On Insertion Sort runs in On Quicksort runs in On logn and Merge Sort runs in On logn To conceptualize these relationships we must refer to each algorithms methods of sorting 00006 00004 ampBubbe Sort wth Rate 9Insertion Sort Quicksort quot39 Merge Sort 00001 Sample Size Bubble Sort and Insertion Sort are both running in linear time because an already ordered set is the best case for both of these algorithms Both of these algorithms only have to make one pass because the set is already sorted Visually we can see Quicksort and Merge Sort are both running in On ogn CASE 2 ORDERED DECREASINGLY The second case of observance comes from comparing the four sorting algorithms when sorting a set already decreasingly ordered Graph 2 illustrates the relationship between each sorting Decreasing Insert 00014 00012 0001 3 00008 H M E 5 00006 Bubbe Sort UInsertion Sort tluicksort NMerge Sort 00004 00002 15 gxp quotZ P26 g O eoooooooooooooooooo N90 0 W90 if Q90 9 vgo we 699 9 boo 69 Q0 69 00 9 990 hogs 990 Sample Size CASE 3 NO ORDER The third case of observance comes from comparing the four sorting algorithms when sorting a set that has no order Graph 3 illustrates the relationship between each sorting algorithm and its time complexity when sorting a set of this pattern Bubble Sort runs in On 2 Insertion Sort runs in On 2 Quicksort runs in On logn and Merge Sort runs in On logn To conceptualize these relationships we must refer to each algorithms methods of sorting Bubble Sort and Insertion Sort are both running in exponential time because a set with no order is simply an average case for both algorithms Logan Ortega 2 algorithm and its time complexity when sorting a set of this pattern Bubble Sort runs in On 2 Insertion Sort runs in On 2 Quicksort runs in On logn and Merge Sort runs in On logn To conceptualize these relationships we must refer to each algorithms methods of sorting Bubble Sort and Insertion Sort are both running in exponential time because a reverse ordered set is the worst case for Insertion Sort and Bubble Sort is simply running an average case Visually we can see Quicksort and Merge Sort are both running in On logn Random Insert Bubble Sort 9Insertion Sort TQuicksort W Merge Sort A A 9 o 399 o 0 Q o o 0 9 page 99 V00 we age Sample Size Visually we can see Quicksort and Merge Sort are both running in On logn CONCLUSION The case in which the set has no order is the best case to obtain a definitive ranking of the time complexities of the four sorting algorithms This is because all four sorting algorithms are running an average case with no special circumstances Although Bubble Sort and Insertion Sort both run in On 2 it is clear from the graph plots that Bubble Sort would have longer processing times than Insertion Sort Similarly Quicksort and Merge Sort both run in On logn but Merge Sort would have longer processing times than Quicksort Logan Ortega 3 BUBBLE SORT Best Case On Already sorted set Average Case Onquot2 Worst Case Onquot2 Smallest element of set is in the last position INSERTION SORT Best Case On Already sorted set Average Case Onquot2 Worst Case Onquot2 Reverse ordered set QUICKSORT Best Case On ogn Average Case On ogn Worst Case Onquot2 A pivot is selected as the largest or smallest element in the set MERGE SORT Best Case On ogn Average Case On ogn Worst Case Onquot2 At every merge step exactly one value remains in the opposing list no comparisons were skipped

×

×

×

### You're already Subscribed!

Looks like you've already subscribed to StudySoup, you won't need to purchase another subscription to get this material. To access this material simply click 'View Full Document'

## Why people love StudySoup

Jim McGreen Ohio University

#### "Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Anthony Lee UC Santa Barbara

#### "I bought an awesome study guide, which helped me get an A in my Math 34B class this quarter!"

Jim McGreen Ohio University

#### "Knowing I can count on the Elite Notetaker in my class allows me to focus on what the professor is saying instead of just scribbling notes the whole time and falling behind."

Parker Thompson 500 Startups

#### "It's a great way for students to improve their educational experience and it seemed like a product that everybody wants, so all the people participating are winning."

Become an Elite Notetaker and start selling your notes online!
×

### Refund Policy

#### STUDYSOUP CANCELLATION POLICY

All subscriptions to StudySoup are paid in full at the time of subscribing. To change your credit card information or to cancel your subscription, go to "Edit Settings". All credit card information will be available there. If you should decide to cancel your subscription, it will continue to be valid until the next payment period, as all payments for the current period were made in advance. For special circumstances, please email support@studysoup.com

#### STUDYSOUP REFUND POLICY

StudySoup has more than 1 million course-specific study resources to help students study smarter. If you’re having trouble finding what you’re looking for, our customer support team can help you find what you need! Feel free to contact them here: support@studysoup.com

Recurring Subscriptions: If you have canceled your recurring subscription on the day of renewal and have not downloaded any documents, you may request a refund by submitting an email to support@studysoup.com

Satisfaction Guarantee: If you’re not satisfied with your subscription, you can contact us for further help. Contact must be made within 3 business days of your subscription purchase and your refund request will be subject for review.

Please Note: Refunds can never be provided more than 30 days after the initial purchase date regardless of your activity on the site.