Sorting Algorithms: Big-O Analysis and Comparison, Slides of Data Structures and Algorithms

An overview of various sorting algorithms, their time complexities, and their relative performance. Topics include big-o analysis, comparison of o(n^2) algorithms like bubble sort, selection sort, and insertion sort, and comparison of o(n log n) algorithms like heap sort, merge sort, and quick sort. The document also discusses the advantages and disadvantages of each algorithm.

Typology: Slides

2012/2013

Uploaded on 04/30/2013

patel
patel ๐Ÿ‡ฎ๐Ÿ‡ณ

3.8

(15)

80 documents

1 / 52

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Sorting
Algorithms and Analysis
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34

Partial preview of the text

Download Sorting Algorithms: Big-O Analysis and Comparison and more Slides Data Structures and Algorithms in PDF only on Docsity!

Sorting

Algorithms and Analysis

Refresher on Big-O

  • O(2^N) Exponential
  • O(N^2) Quadratic
  • O(N log N) Linear/Log
  • O(N) Linear
  • O(log N) Log
  • O(1) Constant Hierarchy of Big-O functions from slowest to fastest

O(N log N) vs. O(N^2) 0 5000 10000 15000 20000 0 1000 O(N log N) O(N^2)

Two Common Categories Sorting Algorithms of O(N^2)

  • Bubble Sort
  • Selection Sort
  • Insertion Sort Sorting Algorithms of O(N log N)
  • Heap Sort
  • Merge Sort
  • Quick Sort

O(N^2) Sorts

  • Easy to program
  • Simple to understand
  • Very slow, especially for large values of N
  • Almost never used in professional software

Bubble Sort

  • The most inefficient of the O(n^2) algorithms
  • Simplest sorting algorithm available
  • Works by comparing sequential items, and swapping them if the first one is larger than the second. It makes as many passes through an array as are needed to complete the sort

Bubble Sort โ€“ Pass 2

Bubble Sort โ€“ Pass 3

Selection Sort

  • More efficient than Bubble Sort, but not as efficient as Insertion Sort
  • Works by finding the largest element in the list and swapping it with the last element, effectively reducing the size of the list by 1.

Selection Sort โ€“ Pass 1-

Insertion Sort

  • One of the most efficient of the O(n^2) algorithms
  • Roughly twice as fast as bubble sort
  • Works by taking items from unsorted list and inserting them into the proper place.

Insertion Sort

O(N log N) Sorts

  • Fast
  • Efficient
  • Complicated, not easy to understand
  • Most make extensive use of recursion and complex data structures

Heap Sort

  • Slowest O(N log N) algorithm.
  • Although the slowest of the O(N log N) algorithms, it has less memory demands than Merge and Quick sort.