0 ratings0% found this document useful (0 votes) 2K views13 pagesDSA Notes MAKAUT 3rd Sem
Handwritten notes according to MAKAUT syllabus
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here.
Available Formats
Download as PDF or read online on Scribd
Hashing _.
_is a _technigue 4, storing and. retrieving _
+ Hash:
. + Hash tfme_. ee
dota” %a OC1)
tap key tenns_welatod to hawohing + :
eet hey Hos table 3 A lato slrucline that
implemen’ “a “mappi om be vabues
uy: Facing a foal oo Keys -
a] 2 Bearehr key tthe vabue/dale ured as _an Fnprule
the hah patlee ceten ming. met
location (inden) whene the Cerseoponding deka
bd atored in hash table’
— Apis ash uncon >
eye way + Bay? a _—
| -Reparoendakon 2 slack nee £
I eee, (00k. CoepPicient >
— — bee mbm
_ stuck ‘node link 5
as — 3p
—_ Pie Tete Tete eee
eaDmplementeion 4, gueve (GT a) :
ae » St
|| Pdrpinn max-steE 400.
|
: Soar,
ik queue Came 626) 5 ink ports in saa,
“eid enquene Cint element) ©:
if (rear 22 MAX: SP2E-))
“ming C* * Gueug, i full );—
if ip De
| pimt
ea tt 5
i a geanr)
VS (iat frets E
4
| — tes r
Bm guene [front -I] ', a
| void display (3 L
jak a : i 5 L.
fe Ke Teo Pee
pt tal Ps tt)
g Oi “\n")
Sak man ¢
enquour. (10) 5
ene c
_ditfe - : segura)
fr Seal” yp dleguatenl ),:
se deaeae2
eae Profin , Pool} Notations -
cedence — O- A= highest “CAL
[aie pascedence ; ES «/ od ie :
iene Lo =
PSE Bt fant bee
wee: C), , TIS rR. Chighesh precedence)
a Convent _ Aspe b- _poatfin forun i:
= Ines Atreke_
{| = ee nang the exp. fi tae
co : a with tur a,
Se eee omq
val,
votd enqueue (shuck qpoue #9, > tak Oe b.
ieee -
Ae reant 1) 4.8. a ee
hints (* Sueue —Geenp bae) 3 — =
= sass somengr
x =
&
eo daqucse Toma qpieue Dt a
ink wal 2
ty gn cua = Soe a
= a CG $usue io enpty ®) —
pl ee ast 4° fronk 75
Garton t qeue
Funclton for invention [enweu’ fn a
a ae (yen) ny, Se ~
oe 29> front fon DH Ge
=— a 6
Creu Queues, . \
-
Gn Spo queues, overt Hme., it cam lead b"
ee
ae! sent LINO UADZL OS temo cure denuevedl
{ sal new ilene” we gengqueued .
queues addres thin Rearing the 4
J
. of
deppeved . Rema ) preventsts memom
bt fat Fnynoving Bpivencs -
~faien poo nagrese 7} can in Cretan qyaue
: Sak fhem)
# faye peri foene ment ie, ebrculan Gpeue
“Ee size 2 G
londlition os incement t- (2 Pt!) Ye 4 Size,.
— fan 6g-2 Dy 62%
— 62 tyopfor|oy
QuEVE
A queue i a linear, list QB elemenls (data shucture
that follows the — First fn first Out (FIPQ) principe,
ie, the element that ta added first is the eme that
in pemoved first -
oy 23 4 5 6 yO ou
[fATe—eTel [.[ [ J > fee] JG
te Front = 0, Rean = 3. fer Front =
Operations on @ueue 2- O Inrznhon- erquenel )
@ eleton - degree).
Conditiona —» © OVERFLOW +
1 Kean. =Max, the GpLue YD replies
__@® _Unoeeriow + 5p FRONT =O, then Queus. io underfls
@ Only one element ia queue 3- If [FRONT ==REAR]
_ A ith Queue Tneenton
_O Sf REAR= MAx , “Queue to overflor” ,
@_ Reap dara -
© Sh FRONT=0, FREES peenrtt
{___ FRONT = FRONT +1.
6) REAR = REAR +4.
a CREAR) = DATA .
_ Whe tee 2 REAR +) .
TInacnton
hap per>
Kao REAR
a
Deletion
happers
fcr FRONT.04-051. ay
” B- Treo
ae
+A B bee % an ordetwise balanced ter .
Ut De maintaths sorted bala. : _
St AL the leap nodes must be Sn same level .
+ the orden Qa Bheo means the maximum nus tao pe
S childxen _e node cur fave. a
For eg 2 Of the orden J a B-breo 5) the mouimum number _
Q a childsen a 4 B-hree can have & 5,
AB bee — order_m’ will have following _prepertion —
| Eveny node. hae manimum —'m' ebuildnen
“Minimum children olen rede should bo O.
5 Piinimun dilden e- soot rede should be 2,
I ninfmum children ed 3 intomal node should be a]
, Bp By erdlen tp 5, [2 ==] S] = fass] = 3. *
The internal nede should have minimum. 3 children ,
) Every rede should howe mantmum (m=) key. fey 2 tee va
4 . every 700
pb mS 7a nadie keke} coy oe
| ~—- a —>é
— Mini uum _ 5, root nade —> 1. x
nti. ox eden => fa) -1 eS
Dae = -—-£L! ?) Unt stack UNI;
il Sint ‘top s | 5
jvid publ) §
| int 5 printf ("Enter dale) 5
| Scanp (“%od.”, La) 5
j (top >= N-!) L
| printh ("Overflow")
| alye. a top +t 3 stack Lop l= x5}
void ©) z Wit itena'
fs tensa =D ~~ ake low
elas = itwAA. = stock C bp);
- Lap =
printf. ("Zch", ile;
id aStok .
2 dsnost “dade sbrucbiine , follows LIPO dele
(lant Tr First Out 5 Geivecbonad imagnkon . ‘
a
* Operations xD farrh. 0) 7 Fnacak ebenacnt me
Oy Popl ) — Remove clement [deletion sealer p
Peck () /%pl) > Bnly give first cheney iG en P)
WD vbmplg () > rcluirane’ Trew 1 starch 1 nypta
© full () 2 xebuure fave. i
akon ch etech
— | 3
{ |
abc Beranaic
(uring Arrays) (uring Unhed Aish)
e-1 by defawll- (in ¥ pining when
ofa (ir Xe kepinedig
» oe
stack “in em )-
Jnviement iF, bap = top td) tren incdem =
stach & full.
Smplement
©,
Ayplicabions —> DReverna a shirg ,() Undlo opp chien ia
(D Recursion — (@) ‘owen. a, dame. ee
= denolis the first eBenrent . 5 Nano elenente
Unde Condihon. for overflow > € i bepes Nea
. s ora
| othenwise, fap wall inereace ,—> boptt ,
stock Loy] = %5Algorithm :Binary Search
Algorithm BinarySearch(A,v):
Input: A SORTED array A of n numbers, search target v
Output: position i where A[i]=v, -1 if not found
low < 0, high < n-1
while low <= high do
mid < (low+high)/2
if A[mid]= v then
return mid
else if A[mid]< v then
low <— mid+1
else
high < mid-1
return -1Case 1: Delete A Leaf Node In BST
Delete Node 20 Deleted Node 20
Deletion In BSTCase 2: Delete A Node With Single Child In BST
Replace 70 With 80 Delete 70
Delete Node 70 After Deletion
Deletion In BST 3SCase 3: Delete A Node With Both Children In BST
Dalete 50
Delete Node 50 After Deletion
Deletion In BST ae