ASU 101 The ASU Experience Computer Science Perspective

  • Slides: 13
Download presentation
ASU 101: The ASU Experience Computer Science Perspective Aviral Shrivastava Compiler Microarchitecture Lab Arizona

ASU 101: The ASU Experience Computer Science Perspective Aviral Shrivastava Compiler Microarchitecture Lab Arizona State University M C L

Why is ASU an NAU? M C L

Why is ASU an NAU? M C L

Today’s Question • What major CS theorem did someone claimed to have proved recently?

Today’s Question • What major CS theorem did someone claimed to have proved recently? • P=NP? M C L

Homework • Write a sorting program in any language you want, and post the

Homework • Write a sorting program in any language you want, and post the solution on your blog. – Should take a bunch of numbers as input. – Should print them out in increasing order. • Also let me know how much time it took you to do the assignment • Deadline: – Sunday 05 Sept 2010. M C L

Sorting • Input: – Array of n numbers, a[0] … a[n-1] • Output –

Sorting • Input: – Array of n numbers, a[0] … a[n-1] • Output – Array of the same n numbers, such that • For each i=0 to n-2, a[i] <= a[i+1] • Is. Sorted(A, n) – Definitely need this ability • O(n) M C L

Random Sort • In loop – If array not sorted • Pick any two

Random Sort • In loop – If array not sorted • Pick any two elements at random, and swap them to put them in the right order – Else • Exit M C L

Permutation Sort • In a loop – If array not sorted • Permute the

Permutation Sort • In a loop – If array not sorted • Permute the elements – Else • Exit; M C L

Algorithm • An 'algorithm' is a method for solving a problem expressed as a

Algorithm • An 'algorithm' is a method for solving a problem expressed as a finite sequence of instructions. – Proof of correctness: always give the right answer and never give a wrong answer – Proof of termination: always be completed in a finite number of steps, rather than infinite number M C L

How fast can you sort? • Permutation sort takes O(n * n!) time •

How fast can you sort? • Permutation sort takes O(n * n!) time • Can sort in O(n 2) time • Need at least O(n log n) time M C L

How do you know problem is hard? • If solving it takes too much

How do you know problem is hard? • If solving it takes too much time. – We kind of felt that O(N! * N) is a bit much complexity • How about O(N 2)? O(N 10)? Where do we draw the line? n – Meet the Computer Scientist Nightmare 2 – So “Polynomial” ~ “easy” & “exponential” ~ “hard” – 2 n eventually overtakes any nk however large k is. . • How do we know if a problem is “really” hard to solve or it is just that I am dumb and didn’t know how to do better? M C L

Exponential growth n n 2 n 3 n 10 2 n 1 1 2

Exponential growth n n 2 n 3 n 10 2 n 1 1 2 10 1000 1010 1024 10000 106 10100 ~1030 1000000 109 101000 ~10300 10000 108 1012 1010000 ~103000 1010 1030 10100 ~10300000 1020 M C L

How to explain to your boss as to why your program is so slow…

How to explain to your boss as to why your program is so slow… I can't find an efficient algorithm, I guess I'm just too dumb. I can't find an efficient algorithm, because no such algorithm is possible. M C L I can't find an efficient algorithm, but neither can all these famous people.

Homework • Write a sorting program in any language you want, and post the

Homework • Write a sorting program in any language you want, and post the solution on your blog. – Should take a bunch of numbers as input. – Should print them out in increasing order. • Also let me know how much time it took you to do the assignment • Deadline: – Sunday 05 Sept 2010. M C L