Thanks to visit codestin.com
Credit goes to www.scribd.com

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

TC2 Lecture Note

Uploaded by

Parth Pathak
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)
82 views11 pages

TC2 Lecture Note

Uploaded by

Parth Pathak
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

Topic08

twoalgo
Comparing

usingexecution
I always I joined is min late
using iteration
canyonrepeateverything
start 705AM Unfortunately No becauseoftime whybigonatation
I can quicklyshownates so you green whyomitlowerterms
taken screenshots later whyomitconstant
can watch the recording to belt
you
Catchup
Issues withbigo
preparetwo versionsof your
constants
interview large 0
work experiencesummary same
tip
short 3min For coding system keepitbevief.EE
design intro is justice breaker
10 20minforhiringmanager
long
projectdeepdive
Iman industryexpert we benchmarkprogramsbyruntime
execution wedonatneedonotation
Isthetrollright

strory
sorting
Algo
competition pygoggpo Algo2 Alice
15sec lose
do
Macbook Pro M2
win PC2010
I
MayboffProy2
10sec
d d
Ctt Intelcompiler python
Intelcompiler
I Ctt

7sec star
de
north
volcano Hawaii manner pole
Sotc f
Northpole 5sec
5sec

Executiontime depends on so
many params
Conclusion

we cannot merely use it for comparing the efficiency

of algorithms
Pat mat
stony

Algo'd Algol SEE


neg iter810day iter g
ioxlagy 30 144 102.4
go https://www.desmos.com/calculator/dfs4y5xkfw

tim sort
de
python Yo
lolagn
40
SI
Algo'd Algo

iters we focus iter

Whyanalysis forciso ioniitt


n to
forlange why E
numbers

searchresult in Google
we are
at the online streaming

age of of users of socialnetwork


big dater
CLRS
Intro Algo Book
AsymptoticAnalysisofAlgorithms
AnalysisofAlgorithms forlargeinputs
no
what
tight lease about
Qr
https://www.scaler.com/topics/asymptotic-notations/
o.w d
typeratffwdboth best
worst
Big O notation average
d
1 iterations based on input size why don't
runtime is be
2 omit all lower terms why notenough confused
teraindstaptiarable
beaware
3 omit all constants coeff why of some
websites
with
story https://www.desmos.com/calculator/4ihihjoslh
g master wrong
Info
on
n't Ion
input iteration i ofton term
n 10 102 10102200 1001.2501

1042 101102 18103 Woot 101


N 1002102

5
n 104 108 105 100 0 li
1 5
rock
kevinhart

story
g g
iterations
10lagh
o lagu 100 Ocn
login n

1000
login Mo
Malaga l00xn

https://www.desmos.com/calculator/tjqkvuak17

tolayn
Issues with big 0
1
large constants mask
story
itert
on
qtr
1000N n
on

hey 104 102

n 100 105 104W

103 106 106


n

no 103 1 10 103 1 103 1 103 1

2 When Ois same


story
ton
try any
on q q
I
itert 2h44m 3h

we cannot clearly comparetwo algosonly by


O notation
a 3 7 s 10 12 1717 12 12 13

booefitra.int'k'll KT
as test
forciso i a Leniitt iteration
a
itlaci tell u
iteration
ret true

3 Y
ret false
g
IS IimeComplexity StSpace Complexity
extintfunctlentn
intYen 4 4 8 1GB
inty Xin
TB
langz 2 9 2
ret Z 8B constant SC
0116 011
a
Xx no o no 2011
ext
intfunctlinta neo 160 4 10B 5GB
inti n
n 103 160 4 10 B 401GB
inty Xin
TB
8BelangZ 2 9 2
it all new
array n Axn
retz Sc O Attn
SC8OCn
ex3 int functlint a
inti n n
int Xin
y TB
8Belong Z 2 9 2
n
it all J new
array n n

ret Z
SLOCAN
SOON

ext bool find intl int ka a Lenisn


forCiro i a Leni Itt o 4B 011
if aci k
ret true
so
P
ret false
g
input algorithm output
data data
FAQ get
whynotinput data outputdata auxuliry space
I saw a reputablebook websiteconsiderthem
whataboutinterview Sc analysis
I am still notconvinced
let's fight Jk
Can I askthis doubt 1000times
Fy repeated till theendof advance
DSA Yes noproblem
y
a Len on

exs it fumes intact


int PSC new intca Len
PSCO ACO
forfielsica Len Itt scooo n 2
04 1000
O uz
PSE PSCI 1 tacit
let Psca Len D 4 106 85

4 103 KB
IIE Time Limited Exceeded MLE
Shubham Google band
story interview

TLE
How to estimate runtime
se
Assumption't 1GHz
CPW
10 opergatig
f 2sec
10 iteration
GByly
Assumption28 010 x

forci K
into Q 3 5
t 10 OH 10 I
Its 1057100210

constraints on 10km
OCU
7104 104 100
I
How to approach a problem checktheConstaints8

- Read the Question and Constraints carefully.


- Formulate an Idea or Logic.
- Verify the Correctness of the Logic.
- Mentally develop a Pseudocode or rough Idea of Loops.
- Determine the Time Complexity based on the Pseudocode.
- Assess if the time complexity is feasible and won't result in Time Limit Exceeded
(TLE) errors.
- Re-evaluate the Idea/Logic if the time constraints are not met; otherwise, proceed.
- Code the idea if it is deemed feasible.

011 Cantant TC
o n Linear to
o
flagn logarithmic
0 U2 O n3 O nd Polynomial TC
0 2 0 3 0 non exponential Te
o en factorial To

TC vs SP
iteration memoryconsumption
usually the largest
array matrix i define
part of solution
both are defind based on input size n
it is the same n

You might also like