I want to mension that All of here are just practice, I took notes of the foundamental and relevant concepts on my personal digital NoteBook. In a future I try to add about graphs and document more (specificly the boundary cases of each)
I also am trying to combine with the book( only practices ):
"Data Structures and Algorithms in Java" by Michael T. Goodrich (Author), Roberto Tamassia (Author), Michael H. Goldwasser.
-
Define what exactly is an algorithm
-
Find a maximum element in an array
-
Find a minimum element in an array
-
Find the 17th element in the fibonacci sequence
-
Calculate the factorial of a number
-
Calculate the sum of the digits of a positive integer
-
etc.
input >= 0inputis a positive integer
- Functions do more work for more input
- Pass by each(
<arr_size_100>) ->100times - Pass by each(
<arr_size_1000>) ->1000times - Pass by each(
<arr_size_n>) ->ntimes
- Pass by each(
- Drop all constant factors
log_2(n) + 1->log_2(n)3n + 2->n50n->n
- Ignore lower order terms
3n^2 + 2n + 1->n^26n^3 + 2n^2 + 3n + 1->n^3
- ignore base of logarithm
- we can change the base, the algorithm will be the same
log_2(n)->log(n)log_10(n)->log(n)log_3(n)->log(n)
- Big-O
same or faster
- Little-O
faster
- Big-Omega
same or slower
- Little-Omega
slower
- Big-Theta
O()andOmega()are the same
-
n^3 = O(n^2)->false -
n^2 = O(n^3)->true -
n^2 = O(n^2)->true -
(n(n-1))/2 = O(n^2)->true -
(n(n-1))/2 = o(n^2)->false -
n^2 = o(n^3)->true -
n^2 = o(n^2)->false -
n^3 = o(n^4)->true -
n^4 = Ω(n^3)->true -
log n = Ω(1)->true -
n = Ω(log n)->true -
n = Ω(n)->true -
n = Ω(n^2)->true -
n^2 = ω(n)->true -
n^3 = ω(n^2)->true -
log n = ω(1)->true -
n = ω(log n)->true -
n^2 = Θ(n^2)->true -
n^2 = Θ(n^3)->false -
n^2 = Θ(n^2)->true