CS120: Lecture 13 - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

CS120: Lecture 13

Description:

... 13. MP Johnson. Hunter. mpjohnson_at_gmail.com. Agenda. Go over MT ... Gmail, Msft's & Apple's future OSs. Very well studied problem. Will talk about several algs ... – PowerPoint PPT presentation

Number of Views:36
Avg rating:3.0/5.0
Slides: 10
Provided by: MJoh8
Category:
Tags: cs120 | lecture | mail

less

Transcript and Presenter's Notes

Title: CS120: Lecture 13


1
CS120 Lecture 13
  • MP Johnson
  • Hunter
  • mpjohnson_at_gmail.com

2
Agenda
  • Go over MT
  • Review ord-of-mag est
  • Programming
  • Algorithms ? programs
  • Pseudocode
  • JavaScript

3
Future Agenda
  • More algs
  • Sorting
  • Gcd
  • Poly eval?
  • Recursion
  • Towers of Hanoi
  • Programming Java

4
Sorting
  • Ideas?
  • Selection sort
  • Worst-case time?
  • Is it ever faster?
  • Insertion sort?
  • playing cards intuition
  • Worst-case time?
  • Is it ever faster?
  • How to get faster? Later

5
Sorting
  • Very important problem
  • Maybe single most important
  • Sorting searching
  • Although fashionable idea Search, dont sort
  • Gmail, Msfts Apples future OSs
  • Very well studied problem
  • Will talk about several algs
  • Insertion sort
  • Selection sort
  • Worst-case v. best-case

6
Why important?
  • Sorting is very common
  • Supposedly mainframes spent 25 of all time
    sorting
  • Sort email, sort files (by name/date), etc.
  • Sorting makes other ops/algs easier
  • After sort
  • searches take logn
  • Eg Search phonebook by name v. by number
  • Search for song in record store
  • Find median is easy (how?)
  • Find if array has duplicates is easy (how?)
  • Find mode is easy (how?)
  • 5. How to create convex hull?
  • Given unordered set of pts, hard
  • But sort by x value ? now easy

7
Menu of sorting algs
  • Th(N2) is easy, but slow
  • Insertion sort
  • Selection sort
  • Bubble sort
  • First major sub-quadratic alg Shellsort
  • Donald Shell
  • O(N1.5)
  • Took many years to analyze time
  • best nlogn
  • Merge sort
  • Heapsort
  • Treesort
  • Quicksort (in practice)
  • Will prove these are optimal
  • Special bucket/radix n

8
Abstraction simulation
  • Same logic with M-W and students-hospitals
  • Meaning doesnt matter
  • Computer only needs the logic/alg
  • Computers can play chess, without understanding
    the game
  • Computers can simulate the weather, without
    getting wet
  • Computers can simulate intelligence, without
    being intelligent (?)
  • Chess, help with hw, make jokes, debate the movie

9
Next Programming
  • Algorithms ? programs
  • Can express in pseudocode
  • But must code in some prog lang
  • This week lang JavaScript in webpages
Write a Comment
User Comments (0)
About PowerShow.com