L-1.2: What is Algorithm | How to Analyze an Algorithm | Priori vs Posteriori Analysis | DAA
Algorithm Definition
Overview: This section provides an overview of what an algorithm is and how it is used in programming.
Definition:
An algorithm is a finite set of steps to solve a particular problem. It can be written in any programming language, such as Java, Python, or C++. An algorithm should contain a finite number of instructions that take a finite amount of time to execute.
Analysis:
Analysis of algorithms involves comparing two or more algorithms based on their time and space complexity. This is done by looking at the independent execution of commands, regardless of the hardware used. Time complexity is determined by measuring the amount of time it takes for a program to execute, while space complexity is determined by the amount of memory used.
Example:
As an example, consider a program that adds two numbers together. The algorithm for this program would be: Step 1: Read A; Step 2: Read B; Step 3: Let Sum = A + B; Step 4: Print Sum. This algorithm contains four instructions that take a finite amount of time to execute.
Understanding Dependency and Approximate Value
Overview: This video covers the concept of dependency and approximate value, as well as the different types of notations used to represent them.
Dependency
- Dependency is a measure of how much one variable depends on another.
- Codependence is when two variables are dependent on each other.
- Uniform value is when a variable is dependent on itself.
Approximate Value
- Approximate value is an estimation of the exact value of a variable.
- Big O-notation, Big Omega notation, Small Omega notation, and Small Omega notation are all used to represent approximate value.