0% found this document useful (0 votes)
6 views20 pages

Algorithm 05 July 2025 Class Notes

The document discusses various algorithms and data structures, including Minimum Spanning Trees (MST), Huffman coding, and task scheduling. It outlines methods for encoding and decoding messages using Huffman coding and presents examples of task scheduling based on deadlines and profits. Additionally, it touches on dynamic programming concepts and Fibonacci sequence calculations.

Uploaded by

aloks94485141
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)
6 views20 pages

Algorithm 05 July 2025 Class Notes

The document discusses various algorithms and data structures, including Minimum Spanning Trees (MST), Huffman coding, and task scheduling. It outlines methods for encoding and decoding messages using Huffman coding and presents examples of task scheduling based on deadlines and profits. Additionally, it touches on dynamic programming concepts and Fibonacci sequence calculations.

Uploaded by

aloks94485141
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

Leane -20 O5/07/2025

-’t2653| /
2 45362

312 4b3 )
I 23451
- 5A6

7 anapt G with nvetes, edes

choose min cast edge (u, v)


IJ (u,v) not forms yk in MsT
Then Add Cu,)it MST.

MST beces e-) egs (o)


Ne mre edy eft inhyd
4 2£

20
35 6

|6

12/

45

wed tot tet nent min cost


o notin MS T.
ede fons
wohase TC: 9i)
TC f Fid ) : O)
TC l lrion C): 9)
tlnion lis): Uning ot tao dijoit sett.
Fd li) : Fnd set name f whik elmeit is iis md
S=£ , 2,3 3 =

PCiJ
2 3

Clnion ,4)

Eind e): 1
Find (3):
Find (9) 7
Fcd ( ) :
Selbetd Min Cost edye (u, )

Union (Fnd (), d(V))

Min cast -)
edae 1 A E F GH
G

0.8) {9.83.{e ,o, E , o ,

e)
SE)

06) ABY,LCE, G. H, D}, fry


DE)X
BE) A, 8, <, Ey6. H, p3,f F}
(Bc)x
3(8,D) X
9, D)x
o {A, 8,c, E,6, H,D, F}

#,9,G,B,(Ge,E»,o).g) )
Hlg Knuskals Cn, e, costCOZedge L J)
[JI)
e edas
basud on prionit Mis Casted.
A Defne Dijait Seta fr nwtis iniill nat
Min Catt=0; in MS T

e, v) = Del_Mi, Misteyo C$) lg e

le)

TLiJL) =0;
TCDC2]= v;
msTast= nET cast t costla, );
ilionly);eli)
3
etin TCJC, MST cat

2
A

H
C

msT
e: number of edge logn loge
L Wsig Min hasp )
doge 2n
Sotd Liked List
ps used in
knuekals
Set aay. Jor nim l)fd
)

Soitd
2
4 5

> Whats TC e Knukal ayo i ed a giy


wnialt ?
a>oln) ole kogn)
(optial Peafin encodig nitiod
encodiy : chas ta binay
decodig :

encodiy:
Using n bit Atast 2 das Con mcode

Toencode bit
ASCI (ues( 7 bit pes ch)
Paitdu/ a-z ,A-z
cha Lo-9, ts-,*/ e,
/96t 1o1)
=7 bit

UNI: itom encodiy


ERcady of mult Langung l6 bit encodsy
No dileene botien Mast fequt ud chas llst
eut ed ehar in tms ot langth [# bit)
’ Oesall mesluge diye Inereales
Moe # bit to ilore
mesdage.

Coptl prefin encediy metad )


baiic Idea :
Mat reguunt ud cha etonit byus not bit
Least fegut wed chas npdent by
So tht ressage
1
minimises.
lngttTotl bit to sbe message]a
a: llo Io
b lo XX notpas! shadd nt code for, ory sthe
prefin of chay
sthes
aaa bbaaa e aaa bbe y

e-72

’ be-egiamanit

. way

Crisen n ehass pegun count


n chas

21 Det ti min weigt toes merge nto ne Z


Lesertntoliat ftees.
n= 9 lha

chas :
U

freguney: 79+ 3454 )S2+ 8+ 20l +48


+ 15+54t l00

Hufman Txes:
ty
348 152

ny

(330) (625)
((9 (27
20|
348
125
201

79 loo
152
79 100

48
Char Heffman ad

100 100 (6bib )

100 21
100 Lo1

1) I> Minimams nambe bit 2


> Menimun pumbe
bit 6
che using Huan
Code
sing Human cadiy to cncode meage ?
n

S Wi di

di =

2-way mge Je
- 23+7|+25 + 2 +625 t179 +3Po+ lonc

+485 +1523 + 3YB 2

Pys bib /char by using Halfran Coding to o


encode message?
2685
Sum of Jeguny f chay = 2-67 bit lehas
wht is dcod wd in messge whik gpat
cin Huffran cod ?

encode L tige>ooo o|lo| lDolooI0o ||_

Fred Lengtd loo5


= Y02o bit

Jot Schedule bused


n Tasts eacd Tash T: witt deadla Te
and proft ei
II Tash Ti inihd on/ bee keadle di
Ther esult proft Pi
otheuiue no prft.
Selede
D retash can esecute atany tne.

3] Each tash seguined onby re unileneculi Jme


Sulict DBms DS Toc

3)
13) 9 (15) 5
Days to 3 y 2 2 2
finisk 5

2 3

JDsmslCN co
D8nscN V 15+12tio+I3 1s
=65

Sub T Te T3 Ty Ts
13

Deadline 2 3 3

2 3
|TeT3 Ts

man paft
L Tast Ti t Tn dortd

Deudlie d[--n
Plt pLl-- -n] gis
fl St Tasts in lecreaing nde tai praft

Choae tak Ti abeve d itt desdlne k di


Schedal as passibl desdbs tne fom dib
Ctieuaise diacard tsh Ti

Fad Nambes

Fabln) =
1

Fib (1) = (Ebli-) + Fzbli-2) ,i>)


1
1
b) T t hecunsie sobti, but not ausidd necomputta .

o n =EO)

ele
hita Ci) ;
net (Fidin-) + Fd (n-2) );
13

F(s)
F(S) F)
F) F3) 3) 2F)
3
2 F) FU, F
Fs) 2F(2) F)
, ) Flo)
2F(2) F) TF)
1

F)

TC: no.

Ol2")
iiplment fn Fd. Nenles
Prgami
>defi ali--
t ali
Indilse

netirn a Cn]l ale.

2 3
6
2 3 5
etiy
boto
Iititse Lsalu

Ed_DRn)

aLo] = ali] = 1;
Jo (i=2; iSn,; itt)
t aco= a[i-0 +a [i-2];
3
nitin Calr);
3
TC: Oln)
SC: 9Cn) / ary pae a[o--- n]
2 TC wsiy brub fore
37 heusne Reltos with te base condtan
Inplmettin DP aips
Define Spae

TChSc using DP

vitm l1);
ele

orli=o; i sn; itt)


2 2°+2'-- [e+e2'+ I+
l=2
3) 2)
SC:tn) la [o-- n]se
Spae
Walo-.-n]
alol=1;
bli=4; i7n ;i+t) 2

=9ln2)

3 al;
alil=sum
Atian laEnJ);

2 4

k (

LCS

2 (AP SP
TC:C 2
23

You might also like