diff --git a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/100-big-o-notation.md b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/100-big-o-notation.md index b4f1f8bb3..e42b36ad7 100644 --- a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/100-big-o-notation.md +++ b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/100-big-o-notation.md @@ -1 +1,10 @@ -# Big o notation \ No newline at end of file +# Big O Notation + +Big O Notation describes, how well an algorithm scales with the input size. It is used to describe the worst case scenario of an algorithm. It is used to compare algorithms and to determine which algorithm is better. + +Free Content +Big O Notation — Calculating Time Complexity +Big O Notations +moviesCS 61B Lecture 19: Asymptotic Analysis +Big Oh Notation (and Omega and Theta) + diff --git a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/101-big-theta-notation.md b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/101-big-theta-notation.md index baa9c2a65..58b3d7561 100644 --- a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/101-big-theta-notation.md +++ b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/101-big-theta-notation.md @@ -1 +1,7 @@ -# Big theta notation \ No newline at end of file +# Big Theta Notation + +While Big O Notation refers to the upper bound of a function, Big Theta Notation refers to the exact bound of a function. Big Theta Notation is used to describe the exact growth rate of a function. It is denoted by the symbol Θ. + +Free Content +Big Oh Notation (and Omega and Theta) +Asymptotic Notation - CS50 diff --git a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/102-big-omega-notation.md b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/102-big-omega-notation.md index 4a6da1910..9e34149b8 100644 --- a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/102-big-omega-notation.md +++ b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/102-big-omega-notation.md @@ -1 +1,7 @@ -# Big omega notation \ No newline at end of file +# Big Omega Notation + +Big Omega notation is used to describe the lower bound of a function. It is the opposite of Big O notation. While Big O is used to describe the worst case scenario of an algorithm, Big Omega is used to describe the best case scenario of an algorithm. + +Free Content +Big Oh Notation (and Omega and Theta) +Asymptotic Notation - CS50 diff --git a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/100-constant.md b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/100-constant.md index 8217679b3..f14d0cee5 100644 --- a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/100-constant.md +++ b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/100-constant.md @@ -1 +1,7 @@ -# Constant \ No newline at end of file +# Constant + +Constant time algorithms are the simplest and most efficient algorithms. They are algorithms that always take the same amount of time to run, regardless of the size of the input. This is the best case scenario for an algorithm, and is the goal of all algorithms. + +Free Content +Big O Notation — Calculating Time Complexity +Big O Notations diff --git a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/101-logarithmic.md b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/101-logarithmic.md index 4d4f50386..02431f090 100644 --- a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/101-logarithmic.md +++ b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/101-logarithmic.md @@ -1 +1,7 @@ -# Logarithmic \ No newline at end of file +# Logarithmic + +Logarithmic complexity algorithms are the second fastest algorithms. They are faster than linear algorithms, but slower than constant algorithms. + +Free Content +Big O Notation — Calculating Time Complexity +Big O Notations diff --git a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/102-linear.md b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/102-linear.md index 52d8c399b..3c8425ff6 100644 --- a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/102-linear.md +++ b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/102-linear.md @@ -1 +1,7 @@ -# Linear \ No newline at end of file +# Linear + +Linear algorithms are algorithms that have a runtime that is directly proportional to the size of the input. This means that the runtime of the algorithm will increase linearly with the size of the input. For example, if the input size is 10, the runtime will be 10 times the runtime of the algorithm when the input size is 1. If the input size is 100, the runtime will be 100 times the runtime of the algorithm when the input size is 1. + +Free Content +Big O Notation — Calculating Time Complexity +Big O Notations diff --git a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/103-polynomial.md b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/103-polynomial.md index 3075e034f..33ea677c1 100644 --- a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/103-polynomial.md +++ b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/103-polynomial.md @@ -1 +1,14 @@ -# Polynomial \ No newline at end of file +# Polynomial + +Polynomial algorithms are algorithms that have a runtime that is a polynomial function of the input size. This means that the runtime is a function of the form `n^k` where `k` is a constant. For example, the runtime of the following algorithm is `n^2`: + +```python +def polynomial_algorithm(n): + for i in range(n): + for j in range(n): + print(i, j) +``` + +Free Content +Big O Notation — Calculating Time Complexity +Big O Notations diff --git a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/104-exponential.md b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/104-exponential.md index b30d7eca5..f36a35ada 100644 --- a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/104-exponential.md +++ b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/104-exponential.md @@ -1 +1,16 @@ -# Exponential \ No newline at end of file +# Exponential + +Exponential algorithms are those that grow at a rate of 2^n. This means that for each additional input, the algorithm will take twice as long to run. The following function is an example of an exponential algorithm: + +```python +def exponential(n): + if n == 0: + return 1 + return 2 * exponential(n - 1) +``` + +As you can see, the algorithm's runtime grows exponentially. For each additional input, the algorithm will take twice as long to run. + +Free Content +Big O Notation — Calculating Time Complexity +Big O Notations diff --git a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/105-factorial.md b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/105-factorial.md index dccb74ed2..df4743887 100644 --- a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/105-factorial.md +++ b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/105-factorial.md @@ -1 +1,11 @@ -# Factorial \ No newline at end of file +# Factorial + +Factorial complexity algorithms have a runtime of `O(n!)`. This is the worst case scenario for an algorithm. Factorial complexity algorithms are very inefficient and should be avoided. + +```python +def factorial(n): + if n == 0: + return 1 + else: + return n * factorial(n-1) +``` diff --git a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/readme.md b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/readme.md index af5796298..3f6b63c58 100644 --- a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/readme.md +++ b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/103-common-runtimes/readme.md @@ -1 +1,17 @@ -# Common runtimes \ No newline at end of file +# Common Runtimes + +Given below is the list of common algorithmic runtimes. The runtimes are listed in ascending order of their complexity. + +* O(1) - Constant +* O(log n) - Logarithmic +* O(n) - Linear +* O(n log n) - Linearithmic +* O(n^2) - Quadratic +* O(n^3) - Cubic +* O(2^n) - Exponential +* O(n!) - Factorial +* O(n^n) - Polynomial + +Free Content +Big O Notation — Calculating Time Complexity +Big O Notations diff --git a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/readme.md b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/readme.md index 4e12618e8..9065c74b6 100644 --- a/content/roadmaps/103-computer-science/content/103-asymptotic-notation/readme.md +++ b/content/roadmaps/103-computer-science/content/103-asymptotic-notation/readme.md @@ -1 +1,16 @@ -# Asymptotic notation \ No newline at end of file +# Asymptotic Notation + +The efficiency of an algorithm depends on the amount of time, storage and other resources required to execute the algorithm. The efficiency is measured with the help of asymptotic notations. + +An algorithm may not have the same performance for different types of inputs. With the increase in the input size, the performance will change. + +The study of change in performance of the algorithm with the change in the order of the input size is defined as asymptotic analysis. + +Free Content + +Asymptotic Analysis: Big-O Notation and More +Big O Notation — Calculating Time Complexity +Big O Notation in 5 Minutes +Asymptotic Notation - CS50 +CS 61B Lecture 19: Asymptotic Analysis +Big-O Cheat Sheet