FDS Lecture 1
Chapter 1 & 2
ERROR in the approximate is called EULER’S CONSTANT(
A is congruent to B modulo N can be written as:
Proving by INDUCTION or CONTRADICTION or COUNTEREXAMPLE
Brief of Recursion
- Base cases. You must always have some base cases, which can be solved
without recursion - Making progress. For the cases that are to be solved recursively, the recursive
call must always be to a case that makes progress toward a base case. - Design rule. Assume that all the recursive calls work
- Compound interest rule. Never duplicate work by solving the same instance of a problem in separate recursive calls
Algorithm Analysis
IMPORTANT MATH NOTATIONS!
Big-Oh Notation
if there are positive constant and such that when Omega Notation
if there are positive constant and such that when Theta Notation
if and only if and Little-Oh Notation
if and To establish a relative order among functions
- Big-Oh - Growth rate is less or equal to
- Omega - Growth rate is larger or equal to
- Theta - Growth rate is equal to
- Little-Oh - Growth rate is less than
- Big-Oh - Growth rate is less or equal to
Determination of
How to determine the growth rate of
Calculate:
- The limit is 0: This means that
. - The limit is
: This means that . - The limit is
: This means that . - The limit oscillates: There is no relation.
Whenever possible, algorithms be efficient enough not to be the bottleneck of a problem
Rules for Algorithm Analysis
R1—FOR LOOPS:
The running time of a for loop is at most the running time of the statements inside the for loop (including tests) times the number of iterations.
R2—NESTED FOR LOOPS:
Analyze these inside out. The total running time of a statement inside a group of nested loops is the running time of the statement multiplied by the product of the sizes of all the for loops
R3—CONSECUTIVE SATEMENTS:
These just add.
R4 - IF/ELSE
For the fragment
1 | if(Condition) |
the running time of an if/else statement is never more than the running time of the test plus the larger of the running times of S1 and S2
If
Then
Ways to Calculate the Time Complexity
- Declaration counts for NO TIME
- Initializing, judgement, operation counts
- NO NEED to take all the statement into acount
Fibbonaci
1 | int Fib(int N){ |
From
Therefore, Fib(N)
>
- Title: FDS Lecture 1
- Author: Yuze-L
- Created at : 2023-09-22 08:59:54
- Updated at : 2024-07-15 11:38:38
- Link: https://yuze-l.github.io/2023/09/22/FDS-Lecture-1/
- License: This work is licensed under CC BY-NC-SA 4.0.