Mathematical Notations and Functions
Floor and Ceiling
n is called the floor of X if nif n is the greatest number that is smaller than
X
n is called the ceiling of X if n is the smallest number that is greater than
X
Remainder Function [modular arithmetic]
Integer and Absolute Value
Decimal is not an integer : 3.45 is a decimal , 3 is an integer .
Absolute value of X : gives the positive value of X even if X is negative
Summation - Given the limits of a particular variable the values each index of that variable hold will added to the return of the summation function
Factorial - Same as the summation function but the operation here is multiplication the product is returned in as the final value from the function
Permutations - Suppose a set contains a few elements , the arrangements of these elements is called as a permute
The number of arrangements of these elements without any repeatations is called as permuataions
A formula to find the permutations of n number is by factorial
i.e permutations (n) = factorial (n)
Algorithmic Notations
- Name of the algorithm
- Comments
- Data Type
- Variable names
- Steps [declarations / Macros]
- Assignment Statement
- Expression [Conditions]
- Input and Output
- Goto Statements
- End Statements
- Functions or Procedures
Control Structure
The mechanism that allows us to control the flow of the execution are called control structures.
There are four main catergories of control structures
- Sequence
- Simply execute one instruction and then next and then next
This is the default control structure , that most programming languages follow
- Selection
- This depends on a condition
- Based on the output of the condition a particular set of instruction is chosen instead of others
- Therefore , executing both of them is generally impossible, since there are written in parallel controls
We would need another instance acting as a child in order to execute the other set of instruction
- Example :
if-then-else
- Iteration
- It allows some code ( one or more lines ) to repeat itself serveral times.
- It executes the statements repeatedly for a certain number of times as long as the condition is true
- Example :
while , for
- Branching
- This structure allows the flow of execution to jump to a different part of the program
- This category is rarely used in modular programming langauges
- Example:
Go-To
Complexity of algorithms