Maths & Algebra for algorithms in computer science – A Refresher

Prime Number – Positive integer number (greater than 1) that can not be created by multiplying any other 2 Positive integer numbers.

  • Tips-n-tricks
    • 1 is not prime
    • 2 is only “even” prime number. Rest all primes are odd numbers.

Composite Number – Opposite of prime. Positive integer number that can be created by multiplying other 2 Positive integer numbers.

Factorial of n (n!) – Product of all integers from 1 till n = n * n-1 * … * 3 * 2 * 1

Permutations – Permutation is arranging the members of a set into an order. Different order of same elements is different permutation.

Ex: Seating arrangement of John, Tim, Jay –> 1) John 2) Tim 3) Jay is different than 1) Tim 2) Jay 3) John. Order of seat numbers matter here.

 




Combination – Combination is a selection of items from a set, such that the order of selection does not matter. Different order of same element is not different.

Ex: Forming team of 2 from John, Tim, jay –> Team of John & Jay is same as Team of Jay & John. Order has no sense here.

Probability

Probability = Number of wanted outcomes / Total number of possible outcome.

Example: Probability of getting 2 in dice

Number of wanted outcomes = 1 (i.e. face with 2 printed on it)

Total number of possible outcome = Total faces on dice i.e. 6

Probability = 1/6

Logarithm – Logarithm is reverse operation of exponentiation.

XY = Z  then Y = logX Z  i.e.  logX Z = Y

Example: 23 = 8, hence log8=3




Greatest common divisor (GCD) – GCD of two numbers is the largest positive integer that divides both the numbers.

Example: GCD of 40 & 24

Divisors of 40 1, 2, 4, 5, 8, 10, 20, 40
Divisors of 24 1, 2, 3, 4, 6, 8, 12, 24
Common divisors 1, 2, 4, 8
Greatest common divisor 8

Fibonacci sequence –  Sequence of numbers starting frmo 0 & 1 such that each next number is the sum of the two preceding numbers.

0 , 1 , 1 , 2 , 3 , 5 , 8 , 13 , 21 …..

Summation / Arithmetic series / Arithmetic progression



Leave a Reply

Your email address will not be published. Required fields are marked *