0% found this document useful (0 votes)
1 views

lecture 1_ introduction sp24

The document contains notes on various administrative tasks and algorithms, including primality testing and sorting techniques. It discusses the use of specific tools for communication and grading, as well as algorithmic concepts like time complexity and recursion. Additionally, it provides examples of algorithms and their complexities, emphasizing the importance of understanding asymptotic notation.

Uploaded by

daiveekiitkgp
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

lecture 1_ introduction sp24

The document contains notes on various administrative tasks and algorithms, including primality testing and sorting techniques. It discusses the use of specific tools for communication and grading, as well as algorithmic concepts like time complexity and recursion. Additionally, it provides examples of algorithms and their complexities, emphasizing the importance of understanding asymptotic notation.

Uploaded by

daiveekiitkgp
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

Admin stuff See EMAIL

Fontrespont to individual emails


use campuswire
even for
private immunication
with course staff

Tekwebsik brightepad
skeletons
lecture summaries sinal pass

additional holdouts
e g MIT notes

Tivaleingrading
Ilotenwpsolutionsdiscused
Raise hand for questions in room

Wwdisticulttaheconsating
on
purpose I
start early recommend
self grading check website
Inhoemail
Algorithms e

Example primality testing


Input integer Nso

output preme composite


A 1

Time a

it M 2 return
puke
for i 2 to N TT
it i divides N output componte
end for

TITINI

Run
best case N even 1

G
case
average trickyo Fagot
on I
G worst case
Ihiscloss

Best
algorithm
It N
pq min

pig
Else it
p.TW p.q
TwedobetterthohF
Yes Seeres at Erasthothene

IS
fcoutimd.ua
TAI N

say N
10
23
How
many bits to store at
super short
n
countree
NCTIONAINPtltf thic.se
logNP
This case
netog.NO
ICN nCah timmeotACN
k.gg
E
g TA IN IN V5 2

iE
adf.it iii

Is there polyon for primality


Moralsteoprimolity
use bit representation
simplest fastest
need notation
asymptotic

Asymptoticnotation
Covered in recitation Here's idea
Need to compare soon
a
way
or to say 12 m as
constant architecture hi
constant architecture specific
Solutioninotationtcomparetundn

f f an
T.IE f EE
57 3 R E AND
Ster 583 w ÉF
Equal f
see recitation for formalisation example

Traig A 1 n
Input array
sorted version of A
Output lin place for now

www.wiiiia
fI
for 2 to a
j 24k

I
key A j 2 3 4 79
i j 1

while is o A i key
A it A

it i 1
end while
A fit is
key
end for

Example.FI 72
2

722
5
3

23253 j y
034 7415

5
2 3 4 7 9

Ferrectness
Tepveriant
After under AI is processed
in the for loop numbers
All j are sorted version
of A
original I
j

Tweloopuntariantb
chduction
base case 5 1

true for All j B


Assuming
show true for All j
r
i É
Tetiteration slowest it D I

moves to A I
Best case A already sorted

65 Then
Worst Case
54321

TINKEE.IE. E

f E en4
Recursive view of

RecIsaffertonsore
janitor
If he 1 return
Rec A Yecursive
IS n 1

Tfn ifeng 2ton j.sn

If
J
while in Assay

1
A A it AC
it i 1
end while
Afitic key
Td for
Siam
TIM

9904072
Ml VP CEO out literative
CASTISI
Jan Dir

New to think as a
way

Towncomputereen Ahe
recurrence equation

TIn NtTIh
C
TI
n n 1
Th 2

n n 1 In 2 T n 31

n In it 2 T1

miisift.mn

Fatwa
Is
HEAT AND
CEW
is _wr
TÉA AE D
AIT
CEO.TT
MERGE TWO SORTED

eERRAYS A sort 2
MS A P r p
n2
TF
PLZ
I par
g PII
VPI TIE
MS A P q
VP TCE
MS A 9 1 e

Merge A p 9,25
2
FE
A
1

B 1 2 3 4 5 6 89

n a
Tmerge

Itypstracework
TIM
tiny E TIE to
1 11
14 4 TH TED

ffffffq.IE yjf

ftp.fff.iq
In log of
FI
iife

merging

T.CN neog a

TIs n

lessee recursion
thinkily as CEO conqued

divide and
is
very powerful algor
technique
endothuret

It have time space complexity


of MS reuse space

sins

n 514
he 5 8
at ft 2 1

2
an 1
2 I

Treorspaceforms

You might also like