You are on page 1of 11

Data Structures

Class Lecture-2.1

Mohammad Ashraful Islam


Lecturer
Department of CSE, JU
08/15/20 1
Mathematical Notations and
Functions

Question:

a)17 % 7 = ?
b)-17%7 =?

08/15/20 2
Prime Number

• A prime number is a whole number greater


than 1 whose only factors are 1 and itself. That
is if N is prime number then N is only divisible
by 1 and N itself.
• For example, 2, 3, 5, 7, 11 are prime numbers
where as 4, 10, 100, 99 are non prime
numbers.

08/15/20 3
Trial and Error Method
Question : Is 9 prime ?

2 3 4 5 6 7 8 9

9%2 9%3

9 is divisible by 3, so 9 is non prime.

08/15/20 4
Trial and Error Method
Question : Is 11 prime ?

2 3 4 5 6 7 8 9 10

11 % 2 11 % 3 11 % 4 11 % 5 11 % 6 11 % 7 11 % 8 11 % 9 11%10

11 is not divisible by any of them. So, 11 is a


prime number.

08/15/20 5
The Sieve of Eratosthenes
• We need to generate prime numbers upto 30.
• Square Root of √30 = 5.48

08/15/20 6
The Sieve of Eratosthenes

08/15/20 7
The Sieve of Eratosthenes

08/15/20 8
The Sieve of Eratosthenes

08/15/20 9
Growth of function
Big-Oh: gives an upper bound on the growth
rate of a function.
Insertion sort is O(n2) in the worst case
This means that in the worst case it performs at most
c.n2 operations, where c is constant.
Omega: asymptotic lower bound.
Theta: asymptotic tight bound

08/15/20 10
Thank You

11

You might also like