Big O & ArrayList - Carnegie Mellon University
[Pages:31]Big O & ArrayList
15-121 Fall 2020 Margaret Reid-Miller
Today
? Office Hours: Thursday afternoon (time to be announce on Piazza)
? Big O ? Amortized runtime ? ArrayLists
Fall 2020
15-121 (Reid-Miller)
2
How do we determine how efficient (fast) and algorithm is?
Key Idea:
The running time of an algorithm depends on the size of the problem it's solving.
Fall 2020
15-121 (Reid-Miller)
3
Big O: Formal Definition
? Let T(n) ? the number of operations performed in an algorithm as a function of n.
? T(n) O(f(n)) if and only if there exists two constants, n0 > 0 and c > 0 and a function f(n) such that for all n > n0, cf(n) T(n).
Fall 2020
15-121 (Reid-Miller)
4
How long does it take to - say "California" and then - fly to California
The time to fly to California (roughly 6 hours) dominates the time to say "California", so we ignore the time to say "California".
Fall 2020
15-121 (Reid-Miller)
5
Big-O notation
Let n be the size of the problem (input):
Time(n) = 4n + 9 = O(n) Time(n) = 2n2 ? 4n + 1 = O(n2)
Time(n) = log3(n) = O(log n) Time(n) = 3n = O(3n), not O(2n)!
There is no c that satisfies c.2n 3n for arbitrarily large n.
Fall 2020
15-121 (Reid-Miller)
6
More on Big O
? Big O gives us an upper-bound approximation on the complexity of a computation.
? That is, think of Big O as " ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- powershell quick reference security and compliance center v1 0
- arraylist github pages
- java syntax examples
- how to remove elements from arraylist in specific index range in java
- big o arraylist carnegie mellon university
- pnp powershell admin scripts set item level permission
- data structures and advanced programming pomona
- remove object method example
- powershell basic cheat sheet rambling cookie monster
- arraylist multidimensional arrays department of computer science and
Related searches
- carnegie rankings for universities
- f o g o h calculator
- java convert arraylist to list
- java sort arraylist of objects
- change array to arraylist java
- arraylist of string in java
- java arraylist to array integer
- java arraylist initialization
- java initialize arraylist with data
- o jornal o pais mocambique
- big o fibonacci
- big online calculator big numbers