Arpita Shaw - CA1 - DSA
Arpita Shaw - CA1 - DSA
Arpita Shaw - CA1 - DSA
N A M E – A R P I TA S H AW
COURSE – B. TECH
SEMESTER – 3RD
CONTENT
• A LG ORI THM
• W H AT I S T I M E C O M P L E XI TY ?
• W H Y I S T I M E C O M P L E XIT Y I M PO RTANT ?
• E X A M PL ES O F TI M E C O M PL E XITIE S
• C O N C LUS IO N
• REFERNCES
Algorithm
• Se q u e n c e o f s t e p s o n d a t a u s i n g
e f f ic ien t d a t a s t r u c t u r e s t o s o l ve a
g i ve n p r o b l em.
• G o o d A l g o r i t h m s?
• R u n i n l e s s ti m e
• B u t ti m e co m p l e xity i s u s u a l ly m or e
i m p o r t a n t.
What is Time Complexity? WHY IS TIME COMPLEXITY IMPORTANT?
• Pu r p o s e : B i g O n o t a t i o n i s u s e d t o
d e s c r i b e t h e w o r s t - c a s e s c e n a ri o. I t
p r ov i d e s a n u p p e r l i m i t o n t h e t i m e
c o m p l e x i ty.
• E x a m p l e : Fo r a s i m p l e l i n e a r s e a r c h,
where you check each element in a
l i s t o n e b y o n e , t h e t i m e c o m p l e x i ty
is O(n).
• E x a m p l e : I f a n a l g o ri th m h a s a t i me c o m p l e x i ty o f Θ ( n l o g n ) , i t m e a n s t h a t i t s r u n n i ng t i m e
w i l l g r o w a t a ra t e p r o p o r t i o n a l t o n l o g n , r e g a r d l e s s o f w h e t h e r i t ’s t h e b e s t , a v e ra g e , o r
worst case.
• W h y I t M a t t e r s : B i g T h e t a p r ov i d e s a m o r e a c c u ra te p i c t ur e o f a n a l g o r i thm' s p e r f o r ma n c e
a c r o s s a l l p o s s i b l e c a s e s , m a k i n g i t u s e f u l w h e n t h e e x a c t g r o w t h ra t e i s i m p o r ta n t .
• Pu r p o s e : B i g O m e g a n o t a t i o n d e s c r i be s t h e b e s t - c a se s c e n a ri o o r t h e m i n i mum t i m e a n
a l g o r i th m c o u l d t a ke t o r u n . I t s e t s a l o w e r l i m i t o n t h e t i m e c o m p l e x i ty.
• E x a m p l e : Fo r t h e s a m e l i n e a r s e a r c h , i f t h e i t e m yo u’ r e l o o k i n g f o r i s t h e f i r s t o n e i n t h e l i s t ,
t h e t i m e c o m p l e x i ty i s Ω ( 1 ) , m e a n i n g t h e s e a r c h c o m p l e te s i n c o n s t a n t t i m e .
• W h y I t M a t t e r s : B i g O m e g a h e l p s i n u n d e r st a ndi n g t h e p o t e n ti a l e f f i c i e nc y o f a n a l g o r i thm
under optimal conditions.
Examples of Time Complexities
• I n s u m m a r y, t i m e c o m p l e x ity i s a f u n d a me nt a l c o n c e p t i n c o m p u t e r s c ie nc e t h a t a l l ow s u s
t o a n a l y ze a n d c o m p a r e t h e p e r f o rm a n c e o f a l g o rit hm s . B y u s i n g a s y m p t o tic n o t a t ion s l i ke
B i g O, B i g T h e t a , a n d B i g O m e g a , w e c a n d e s c r i be h o w t h e r u n n i ng t i m e o f a n a l g o rit hm
c h a n g e s w i t h t h e s i ze o f t h e i n p u t . T h e s e n o t a tio n s h e l p i n u n d e r s t a n din g t h e e f f ic ien c y o f
a l g o rit hm s a n d i n m a k i n g i n f o r me d d e c i s i on s w h e n s e l e c t in g a l g o r ith ms f o r d i f fe re nt
tasks.
REFERENCES
https://www.freecodecamp.org/news/big-o-cheat-sheet-
time-complexity-chart/ THANK YOU
https://www.geeksforgeeks.org/understanding-time-
complexity-simple-examples/