0% found this document useful (0 votes)
9 views9 pages

Nihar Deshpande Data Ass

The document discusses various concepts related to binary trees, including definitions of complete binary trees, min heaps, and skewed binary trees. It also covers traversal methods, node definitions, and provides examples of recursive functions for counting leaf and non-leaf nodes. Additionally, it includes instructions for inserting elements into binary search trees and sorting methods using heaps.

Uploaded by

anupzaza12
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)
9 views9 pages

Nihar Deshpande Data Ass

The document discusses various concepts related to binary trees, including definitions of complete binary trees, min heaps, and skewed binary trees. It also covers traversal methods, node definitions, and provides examples of recursive functions for counting leaf and non-leaf nodes. Additionally, it includes instructions for inserting elements into binary search trees and sorting methods using heaps.

Uploaded by

anupzaza12
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/ 9

DsA-m SEM 4 Niuerbesupaue

DatedASSMate
Paga
Arsignment -| TREE)

8inary tre CoNtane ewery nade witu


minimun +w0 uid noder true 0rfalie
False
8inary tree contans maimum
nodes
Deioe LettSkewed binan tree
A ee whic eUer node has ony
left Sbtree is called aJ left Skewd onlt na
tree
3
what is conmplete bin ary tree
A
binary tree i said to be Complete binan
tree leuel except Eue (ast
leuel have makmum numbe ot pogbto
nodes aud aul tue nodes ot tte iart
appeQr a s a r let as porrib

Deine min heap


Hep a specal fetion tree-bas
data Struture tree a
Complete binary tree
Minheas min- he tue
Ky preseut at Rue 00t node mst be
minimum tue Fuys prereut at
of among
lildren.

Tue ewel oxd ertrawerSal ot a binary tree


trawerde nodein. level by leve
mann from top- O bott omm and anong
classmate
Date
Page

ttue nodes ot sane eel they are trawerr


from 1et to riqwt
6. (uhat ic descendeNt ia tree 1
Decend entr o tue odes are tho Ne nod er
whica are recheble fomnode.

7. Define deqree tree.


Tue high est deqree anode amo ng all
tue noderio tree s call ea as deqee
tree

List tree twersa methods


dA Tnoroer trawersal
Preorder trauera.
Postorder troweral
Defiae node ot a tree
tree , every individwal elermet is
Call edas noe. t t i s a tree data stuct
that Storer tue actual data of
tuat particular andiok to net.
elenent aus hieraehicalstructure.

2 marks
Show tue steps ot ceatin o binarys
Cu tree for tue following datai
LS 90,20,s 0 2,
(13)
clPagaasssnate
Date

of
any two applicati on
||. List
ree dato
Sture
Hierarical data structre
Data base indexina (8ST
J2.
what isSkewed binary ree)
AA Sk ewed binary ree
bioary tree io wiu
type ot
ttue nodes
are
arranged in Sucl a way Haat t
exEend
only ue one directioYn elthe
Completely to left or ompletely toke
tue niat:
Types of kew ed binay tree are :
left ckewed
Riqut kewed.

Q3 4 marks.

13 write
ite re ursive funcion io'c displau
and cownt leaf node non-eaf
nodes of brt
Cownt Leat ( TREE * noot)
Satic intleaf =O,
NODE * temp = T00t

ifCtemp’ left= NULL) 4


Ctemp’ rigt == NOLL))
eaf tt
CountLeaf (temp’eft)
Cownt Leat temp rig)j
retunleaF
claSSMAte
Date
Page

nt Count_nonLeafTREE noot)
Static int
if Cro0ot == NVLL)
return Cnt,

fCr00t ’ teft = NULL |

Cnt tt

count -nonLeaf( roOt ’ left)


count - nonleaf(root’riqut

write aCfuntiom to
an elemeut
8ST.
Void iosert(TREE
int tao =0
TREE * paret
por * temp

root = ueate Node(c);


elre
pareut
do

pogend temp pureut


pareut= paret eft
else (r > pareut ’ data)
clssmte
Date
Page

1teup = paret i
poreut= pareut ’ riqut

flag ( data already erisH);


printf
br eak4
wiieC pauret l = NOLL 4 fiag =o)
if Cpareut == NULL)
pareut = reateNode r);
ie ( < temp ’ data)
tewp ’ Let = pareut
else
temp ’riqt
riqut =puet;

|S.
write a
C pr o ompare two BT.
int Compare BST TREE AtTREE
A t, t)
Statie int f g =
1 f ( t | = NULL 4 t = z NULL)
return
elre(t NULL 44 ta|ENULL)
iE (t ’ data = t2 data)
ifCompare BsT( ’ t , t2’e=l)
Co mpare 8T(tI’iqut,t 2’riqu
ele
'egu'
classMte
Date
Page

write a c function to find minimun et


Vale nodo from BST
TREE fiod in Nodo Tree* root)
NULL)
printf (" tree is empty)s
reurn NULL 4
wile root ’ det = NULL)
r00tE ro ot t

TREE *findNivalue (TREE * TOot)


TREE * t e p r00t
while temp f tenp ’ t =NU LL)
temptemp ’
return temp

nodu
to inSert a teet
into 8ST:

8ST NODE * inset&ST BSTNOPE *root , int n)


= NULL)
root =(BSTNODE #) maloc(sizeot(BsTNoDE)
r00t data = n
root ’ ett = root ’i ut = NULLY
el se
if ( n < root ’ data)
root ’ 4eft = in certBT(T00t ’let,
elre
r0ot’ riat = iortBST (root’riat
n); retunroot)7
als mate
Date
Page

wacp to sort nrandomly genrat ed


Sort method.
uring
void heanfort alJ
beap
int al]int n)
int i temp top =0, last
build heap (a,n)
piotf ( " n soiial heap ;
diplay (a,n)
fer ((ast = n-|, last >|', lart
temp = a Ltop;
a[ top] = al last),
al |ast] = temp
printf(" AfteN iteration d
n-ast);
display (a,n)
heapify (a, top last -1),?

write a fun cion to rereh an elemeu


BST.
TREE
2 f (ro0t ’ data = c o o t =NULL)
return root ',
it Cr < root ’ data)
return searu (root ’ Latt , )
lre
4 (C> r00t ’ data)
rtturn searu(rOot ’riqut,
clAsSMAte
Date
Page

Q4 3 marks
Define ue followinq terms
te
)Terminal node-The nodes wit no
Sub trees are caled te minalnode
2 Deptu of node - Total no of nodes
edaes from root partila no de
Call ed duptu f ttat node
3) root nodQ In tree datoa shructure
tue firt node from where tw tree
Oriqinater lled as a oot node

2)
2 Crive inoder preorder aud postord er
trauena for:

00

too
"Inonder i 60 700o0 120, 1S0 a00
Preorder: |20 60aO 70, 00 2004
Postoder 70 |00, qO, 60 1S0,2 00, |20

Thorder BAD£IHt
" Preorderi A,B E,HLL
Postord er B DIL, H,E,A
Date
Paga

3)

"rorder cB.A, E,C H,E,I


Preod er == A, BD, c, C,EF,,T
Postorder G, D,8E, HIE, C,A

221 Define tue following term


Heigut of tue tree n a tree, heia t
0f tue root node is sad to be helatot
tue tree.
Porest : A forest i a set o disfoint
trees
3 Siblíng ot a tr
tree Nodes wih belong
to t e pare t are iblinqt

You might also like