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

DSA my

The document outlines algorithms for breadth-first search (BFS) and depth-first search (DFS) in graph traversal, detailing the initialization of data structures and the process of visiting nodes. It also explains Kruskal's algorithm for finding the minimum spanning tree (MST) in a graph and discusses various data organization methods, including sequential and random access. Additionally, it covers hash table organization techniques, including chaining and open addressing for handling collisions.

Uploaded by

iamcharlie1160
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)
10 views

DSA my

The document outlines algorithms for breadth-first search (BFS) and depth-first search (DFS) in graph traversal, detailing the initialization of data structures and the process of visiting nodes. It also explains Kruskal's algorithm for finding the minimum spanning tree (MST) in a graph and discusses various data organization methods, including sequential and random access. Additionally, it covers hash table organization techniques, including chaining and open addressing for handling collisions.

Uploaded by

iamcharlie1160
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/ 6

AssiÇAMENT

Ql c) lite an Algomithn fer BES and DES traveual y a


b BAS (Breadth - fiut Seareh) lgantha (GTaph,
fraph.
1. Jnitialise a Queue and tngutue dhe
Stat_Nade):
dtart. Noc.
Q. Mak cthe SardNocu as tisited.
3. shide he fuee is nat.Empty :
a. Deguye a nocle tom the Queue onc call it Cment-nt
b. Bouss he Cumnt2ode.
C. for each inwsi ked neighbows e the Cmend_nodi
@) Mark the neijhbr as wsi ted.
(à) Enguaue thu neighbour.
DES (Depth-firut Seareh) Alpenithm (Graph, Stay Noda):
J. nihalise a tack and puh the Hant Noce.
. Mans thefant Node ay wisited.
3. White he stack is n0+ Emphyi
0. Pop a nodefrm the Vtack and call it mtnt node.
b. Prouss the Cment nod.
C. for each unusied neighbor the cumntnode :
ti) MenK the neighbor as- Wside d.
W) Puh the neigh bor onto he Sto ch.

(b). Draw and Exblain dhe MSI ing Hrushkal'a Algoithm


o Mgrtho Kkushkal'u algaithm s a grudy gnitha lattd to find
the minimum.Jpanning he (Msi) 9a grph. An MSZ Conects
aLe veatius wh he minimum Posti sle oBal cdoe
weigut
uitheut for uing any ycai.
Rinany Blu
’ These dtoe data in
dinay ermat, wbich
vadahle dut mo iderd. is not
human
Cnuimole tx, dat, bmp
Seque nhial Glu
Recot da in these tilea ae
he tht onganizd dequantily on yter

Random ALcess blesi


.

These tlus al aw Don


Jequential atas to fecoTda
easy to etrjeue dota
dimty. maing it
Exampa i databases, indaed files.

3. Dequenbial bl Organizatian
’ Retods are flore d One aJten
To find a dßeific recrd , the another in a srgential rder
system must stan hom the
bngiming
rompaA bst Smploya sored in Aphabeical rdr by 2ame
o. Direta Random AceAs AL Dgansahien.
Can be atcassed diry cuithoet Janmiag te
wes a hash uncien on à kiy
cubole fl.
locate te date
direty

fnampl Aasing a
h accourd. unben.
ustemer's unt batanct dorecty lwing
Algmithm 4 Kruskal:
Sord all edges n he graph n inouoaing nder g wego
th Mt as an enphy el Edges.
3.
Jnihaliz
PieK he Jmallst edge fhom thu sed Cist, ond chck i
adding it Grates a gee wing the ain-find doda stuclare
4. Add he edge to he MsT it does not -ermn a cycle.
S. Repeat undil tHhe MST Comtaà na (V- 1)edges , whee V is the n
vntiea on th groph.

Exampk
Step J: Sors Edge by wiglt
B-c
C-D
A -c ! 4

Step 2: Aad edges, emswing no cyce


8
2

epi oal weigh, J424 3 E6

Enplain types g fik and Ala ganiz atins in detal.

’ hey dtore data as plan tt, coich ls human- adaba

’ Uard er Stoing (ong'gation fplas, lys on strutued data in a


ada ble forn at.
’ Dad a is acessed eantially .
Aganiatien ile . h indu cotains
J. Jadexd Blindin o lobate mords utin the
lses Qn
bockes dusired
Zoirders to the data the lorahon e dhe
’ Uear ch throughe indax b ind
vcord.

redord in the
4 Haubed Ale Qrganisatien combte e locaton g hu
’et a hash Auncion to
funon,
Qutput thh hsh
Records are ord based on the
lcat'en.
ehich maps a

with @nol cuithout


bplain Guadrabing Pobing and chaining
(6) uih ormpl.
eplacoment
Ruadsatie Lsbing Collisiem-0Lcwrs , he algorithn hies
aUailable latlsing
a quodrate funchim
to fad he mext

new ind1x * (hosh lKey )t cIx it (2*2% tasl-sie.


(Asume the
Q snset Key8 60, 700, 76

hl90) 0% 7:0
is sed Sne 76
Step4: New inse 88

Cowsion
Caladatien
Tvy (st)°%? 2
8te 3s at noek2.

CAALNING
tn chaining, each index in the hub tatlu Gores a inked ist y
that map to that ndo. When a o i'sien Otws, the
eo key s addd to the Gnksd is a thad indan.
kuy: 102s, s 20, 35
Chaining yitalt Replaceent

Qt inde

the indan 0.
loS

oL'sien a hy , ndd to he chan

’ Gli'si en . Add t choù n


to’S- 1S 20
’ Add to chou n
/0’2S ’ s ’ 20 ’ 35

Chaining with Replarunt


hent to

inde
ep2: mgent .

CoWsion, Add S the hn

15 ’ to ’S
Sep 4: msen 20

IS ’ 1o ’ a s ’ 20

h(3s): 35%. S: o
pdd 3S to he chain

You might also like