Download presentation
Presentation is loading. Please wait.
Published byJohnathan Day Modified over 6 years ago
1
ASU 101: The ASU Experience Computer Science Perspective
Aviral Shrivastava Compiler Microarchitecture Lab Arizona State University
2
Why is ASU an NAU?
3
Today’s Question What major CS theorem did someone claimed to have proved recently? P=NP?
4
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.
5
Sorting Input: Output IsSorted(A, n) Array of n numbers, a[0] … a[n-1]
Array of the same n numbers, such that For each i=0 to n-2, a[i] <= a[i+1] IsSorted(A, n) Definitely need this ability O(n)
6
Random Sort In loop If array not sorted Else
Pick any two elements at random, and swap them to put them in the right order Else Exit Random sort is not algorithm; Perm sort is an algorithm.
7
Permutation Sort In a loop If array not sorted Else
Permute the elements Else Exit; Random sort is not algorithm; Perm sort is an algorithm.
8
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 in an infinite number
9
How fast can you sort? Permutation sort takes O(n * n!) time
Can sort in O(n2) time Need at least O(n log n) time
10
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(N2)? O(N10)? Where do we draw the line? Meet the Computer Scientist Nightmare So “Polynomial” ~ “easy” & “exponential” ~ “hard” 2n 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? 2n
11
Exponential growth n n2 n3 n10 2n 1 2 10 100 1000 1010 1024 10000 106
10100 ~1030 109 101000 ~10300 108 1012 ~103000 1020 1030 ~
12
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. I can't find an efficient algorithm, but neither can all these famous people.
13
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.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.