0% found this document useful (0 votes)
29 views11 pages

Problem Solving

Uploaded by

Vikas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views11 pages

Problem Solving

Uploaded by

Vikas
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Yash Raj 20 Dsf

2017 Bits Pilani 4yd I


1
2821 Direct Media.net
2
4
AMIE
Teaching

Aust 1
I
2022 Oct
2018
I 3500
56BA 200g

2 30 hours long

DSI p Pseudo lodes

Lectures 1 24 hours
Atssignment 2 sleep 8
Homework 3 office 88
food both e exes
3
3

D
Count
of factors

anty number which divides N completely

Noli o
i is a factor N
of
N 24 Count
of factors 8 1,2 3 4 6 8
12.243
8

N lo L1 2 5 10

4
Pseudod
int countfactors int N L
int ans 80

for int i 1 isn itt L


Noli D
if arstt

return ans

3
Ayumption

108 iteration 1sec

N iteration Exertiontime
108 108 1sec
1010 10 100sec
1018 1018 100sec

311k
108 iteration 1sec
1 iteration see
Ig
10 iteration 1010 8 102

Brute force Worst solution


possible
Is if i is a factor
N
ixj

j E
Ob 1 factors come in pairs

N 24 N 100

i Nti i Nti
1 24 1 100
2 12 2 50
3 8 4 25
6 5 20
6 4
3
Do 10
8 20 5
12 2 25 4
24 1 50 2

100 I

i I

IET
Pseudocode

int coat factors


int ans o
int N L.EEM
for inti 1 ixion itt L
if Noli o

ie Mi
if ans ans 1
else
9s ants
3
3
return ans Total iteration TN
B
N 36

i ans N
I 2 30

6
God
3 iz

H 8 9
5 8
6 9 6
I
7

N iteration Exertiontime
1018 109 10 seconds

OBSERVATION Most
important
skill

8509mL
02 Given N Check
if N is a prime number

count
of factors 2

Prime numbers are numbers which have


factors I and the number itselfonly
No 1 except I

Pseudocode

bool checkPrime int N L

int of countFactors N

If of 2

return true
else
Seton false

3
HI Optimised

versing
S I 2 3 4 100

Is 8 100 101
s 100 5050
p Grass
S 8 It 2 3 n

25 Pti Inti Int Int


25 A ninth
S f
NII
Given a perfect Square number N
Find the square root of N

int findPerfectsa int N L


for int i I iEN itt L
if Cixi N

return i
3
Amazon Mca
3 D Logan
D N
A
4 None ofthese
I Find squalor
perfect square return
If N is not a

floor sartor

floor x Greatest integer I X

flour 7 2 87
floor 2 9 82
floor 3 03
i ixi
NEE
I I af
2 4 2
I 9 3

22
4 16 4 22

5 25 5
6 36 6
7 49 7
8 64 break

You might also like