270 likes | 516 Views
CSC 490 - Senior Seminar I. This is your most important class!. CSC 490 - Senior Seminar I. CSC 490 - Senior Seminar I. Wassn3 due. sassn0 dates … sassn1 feedback. CSC 490 - Senior Seminar I. are you prepared for class?. quiz list and briefly explain the topic for today.
E N D
CSC 490 - Senior Seminar I This is your most important class!
CSC 490 - Senior Seminar I Wassn3 due sassn0 dates … sassn1 feedback
CSC 490 - Senior Seminar I are you prepared for class? quiz list and briefly explain the topic for today
CSC 490 - Senior Seminar I NTO text chapter 15 first read (abstraction)second read (cognition)refer to supplemental texts
CSC 490 - Senior Seminar I Time & Space complexity Big O notation “O” is Greek Omicron
CSC 490 - Senior Seminar I not basketball …
CSC 490 - Senior Seminar I Not tires …
CSC 490 - Senior Seminar I Not anime …
CSC 490 - Senior Seminar I quick overview Big O notation is used to analyze algorithmsfor efficiency.
CSC 490 - Senior Seminar I Eg, the time (or the number of steps) it takes to complete a problem of size n might be found as: T(n) = 4n2 - 2n + 2.
CSC 490 - Senior Seminar I As n grows large, the n2 term will come to dominate; all other terms can be ignored.
CSC 490 - Senior Seminar I Big O notation captures what remains: we write and say that the algorithm has order of n2 time complexity.
CSC 490 - Senior Seminar I Big O notation O is for “order” purpose: compare algorithms in time & space complexity
CSC 490 - Senior Seminar I Example: which sort is “better?” bubble, shell, quick, etc
CSC 490 - Senior Seminar I bubble sort references: http://www.nist.gov/dads/HTML/bubblesort.html link http://java.sun.com/applets/jdk/1.0/demo/SortDemo/example1.htmllink
CSC 490 - Senior Seminar I bubble sort simplest and slowest way! The basic idea is to compare two neighboring objects, and to swap them if they are in the wrong order.
CSC 490 - Senior Seminar I bubble sort for (i=0; i<n-1; i++){ for (j=0; j<n-1-i; j++) if (a[j+1] < a[j]) /* compare two adjacent */ { tmp = a[j]; /* swap a[j] and a[j+1] */ a[j] = a[j+1]; a[j+1] = tmp; }}
CSC 490 - Senior Seminar I bubble sort Time Complexity O(n2)
CSC 490 - Senior Seminar I quick sort (by Sir Hoare) Pick an element from the array (the pivot), partition the remaining elements into those greater than and less than this pivot, and recursively sort the partitions
CSC 490 - Senior Seminar I quick sort references: http://www.nist.gov/dads/HTML/quicksort.html link http://www.cosc.canterbury.ac.nz/people/mukundan/dsal/QSort.htmllink
CSC 490 - Senior Seminar I quick sort Time Complexity O(n log n)
CSC 490 - Senior Seminar I which sort is “better?” quicksort bubblesort O(n log n) O(n2) time to sort n=1,000,000 20 million steps 1 trillion steps
CSC 490 - Senior Seminar I Chapter 15 problem: find duplicates in a list two solutions: SCAN and STOR
CSC 490 - Senior Seminar I SCAN for i 1 to n-1 do for j i+1 to n do if A(i) = A(J) then output i and j exit else continue
CSC 490 - Senior Seminar I STOR for i 1 to n do if B(A(i)) 0 then output A(i) exit else B(A(i)) 1
CSC 490 - Senior Seminar I ppt … a long time ago in a galaxy far, far away the dangers of ppt