Download presentation

Presentation is loading. Please wait.

Published byNatalie Cruz Modified over 4 years ago

1
Order of complexity

2
Consider four algorithms 1.The naïve way of adding the numbers up to n 2.The smart way of adding the numbers up to n 3.A binary search of n sorted items 4.An insertion sort of n items

3
Naïve summing of integers

4
Smart summing of integers

5
Binary search

6
Insertion Sort Outer loop, increases the sorted section Inner loop, steps backwards to find The right place to swap the unsorted elements

7
Insertion Sort

8
Quicksort Pivot Value Smaller than the Pivot Larger than the Pivot http://cs.slu.edu/~goldwasser/demos/Quicksort/

9
Quicksort Pivot Value Smaller than the Pivot Larger than the Pivot http://cs.slu.edu/~goldwasser/demos/Quicksort/

10
Quicksort Pivot Value Smaller than the Pivot Larger than the Pivot http://cs.slu.edu/~goldwasser/demos/Quicksort/

11
Quick Sort

12
Big O notation O(1) – size doesnt matter, constant –Smart summing O(log 2 n) – Logarithmic - Binary search O(n) – linear – increases with size –Naïve summing O(n 2 ) – Polynomial – increases with square of the size –Insertion sort

Similar presentations

OK

WHICH SEARCH OR SORT IS BETTER?. COMPARING ALGORITHMS Time efficiency refers to how long it takes an algorithm to run Space efficiency refers to the amount.

WHICH SEARCH OR SORT IS BETTER?. COMPARING ALGORITHMS Time efficiency refers to how long it takes an algorithm to run Space efficiency refers to the amount.

© 2018 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google

Ppt on power grid failure images Ppt on high court of india Micro display ppt on ipad Ppt on review writing on books Run ppt on html editor View my ppt online shopping Ppt on emotional intelligence in leadership Ppt on parts of tenses Ppt on leadership challenges Stem and leaf display ppt online