Programming Notes ✍️ – Telegram
Programming Notes ✍️
12 subscribers
65 photos
1 file
22 links
Download Telegram
time complexity linear time calculation
Big O Notation O(n) expression:
1.find the fastest growing term
2.take out the coefficent
Algorithms definition : a set of small steps (tasks) to solve a problem
human ex :
- go to kitchen
- pick up the egg and oil
- heat up the pan
- make an omlete
computer ex:
- wrote an f(n) where n is the array
- create pi_array a variable which should store pi number of num index in n
- write a for loop that loop trough the value , index on n in array
- with every iteration calculate the pi and add it to pi_array
- after ending the iteration return the pi_array
— Time Complexity : O(n) >
O(1) : pi_array + n x O(1) : for loop + O(1) = O(n) => Time grows as input gets larger
Programming Notes ✍️
Algorithms definition : a set of small steps (tasks) to solve a problem human ex : - go to kitchen - pick up the egg and oil - heat up the pan - make an omlete computer ex: - wrote an f(n) where n is the array - create pi_array a variable which should…
some things to note :
- in time complexity calculation we doesn't calculate the memory allocation of something like f(n)
- with every loop in the function the (n) get's powerd by 1 something like : O(n2).
- in time complexity we measure the worst case scenario like if a constant time was 0.0100 we wrote it O(1) because it's never 1 is the worsest scenario.
Mathematically, if f(n) describes the running time of an algorithm; f(n) is O(g(n)) if there exist positive constant C and n0 such that,
Just like O notation provide an asymptotic upper bound, Ω notation provides asymptotic lower bound.