While waiting: quotes - PowerPoint PPT Presentation

About This Presentation
Title:

While waiting: quotes

Description:

We flew down weekly to meet with IBM, but they thought the way to measure ... 9.2 (pp. 465-490) for Friday: mergesort, quicksort, radix sort, algorithm comparison ... – PowerPoint PPT presentation

Number of Views:40
Avg rating:3.0/5.0
Slides: 10
Provided by: stefanb7
Learn more at: https://cse.taylor.edu
Category:
Tags: quotes | radix | waiting

less

Transcript and Presenter's Notes

Title: While waiting: quotes


1
While waiting quotes
  • 640K of main memory ought to be enough for
    anybody. - W. Gates (Founder and CEO Microsoft),
    1981 - disclaimed
  • We flew down weekly to meet with IBM, but they
    thought the way to measure software was the
    amount of code we wrote, when really the better
    the software, the fewer lines of code. - W. Gates
  • Beauty is more important in computing than
    anywhere else in technology because software is
    so complicated. Beauty is the ultimate defense
    against complexity. - D. Gelernter ("Machine
    Beauty", Basic Books, 1998)
  • Good programmers know what's beautiful and bad
    ones don't. - D. Gelernter ("Machine Beauty",
    Basic Books, 1998)
  • Vague and nebulous is the beginning of all
    things, but not their end. - K. Gibran
  • The purpose of computing is insight, not numbers.
    - R. Hamming

2
COS 121 - Nov. 09, 2005
  • A file that big?
  • It might be very useful.
  • But now it is gone.

Stefan Brandle
3
Agenda
  • Read Ch. 9.2 (pp. 465-490) for Friday mergesort,
    quicksort, radix sort, algorithm comparison
  • Guest speaker for WOW
  • MP 3 -- N-queens speed trial
  • Searching linear, binary
  • Sorting Selection, Bubble, Insertion

4
Guest Speaker
  • A guest who builds tents via commercial ventures
  • Keeping name out of lecture notes, because they
    get posted online.
  • This is an important thing to think about.

5
MP 3 Questions?
  • Be sure to read through the Wirth Program
    Development by Stepwise Refinement paper
  • Any questions?
  • Due date is Friday, midnight.

6
Searching
  • Linear
  • Best case 1(not particularly likely or
    meaningful)
  • Average case O(1/2 N) O(N) Drop coefficients
    of N when computing order of magnitude
  • Worst case O(N)
  • Binary
  • Suppose that N 2k for some k. E.g., 8 23
  • Given N, can divide N by 2, k times, before get
    down to 1 item. So k log2N
  • So binary search is, worst case, O(log2N)
  • If N is not a power of 2, then find 2k-1 lt N lt
    2kE.g., for N7, k3.

7
Selection Sort
  • Each pass through the unsorted data, select the
    largest item. Swap it into the sorted area.
  • Demonstrate the sort with plastic cups.
  • Look at code pp. 458-459.
  • Analysis
  • Various ways of measuring algorithmic work, but a
    good approximation is to count number of
    comparisons and assignments
  • Calls to indexOfLargest (n-1) (n-2) 1
    n (n - 1)/2
  • Each of n-1 calls to swap require 3
    assignments/data moves.
  • gt n(n-1)/2 3(n-1) n2/2 5n/2 - 3 gt
    O(n2)

8
Bubble Sort
  • Similar to selection sort. Start at one end of
    unsorted data and start bubbling an item up to
    top of data. Compare two items, swap if
    necessary, so that smaller is closer to top. Then
    compare the smaller of the two with the next
    position and swap if necessary. Keep doing until
    smallest item in array is at top (front) of
    array.
  • Demonstrate with cups.
  • Look at code p. 462.
  • Analysis pass i requires n-i comparisons and at
    most n-i swaps.gt n (n-1)/2 comparisons, same
    number of swapsgt 2 n (n-1) 2 n2 - 2n gt
    O(n2)

9
Insertion Sort
  • Take a data item from the unsorted part of the
    array. Insert it into the sorted part of the
    array. Repeat until all unsorted data has been
    placed correctly.
  • Run through with plastic cups.
  • Look at code on pp. 464-465.
  • Analysis n(n-1)/2 comparisons 2(n-1)
    moves n2 n - 2gt O(n2)
Write a Comment
User Comments (0)
About PowerShow.com