38 views

Uploaded by RizwanIlyas

cs 301

- A Modified Recursive X-Y Cut Algorithm for Solving Block Ordering Problems
- CS301SolvedMCQs
- Syllabus
- chatzikyriakidis-phdthesis-revised2.pdf
- Computer Notes - Data Structures - 24
- Ggg
- most_important
- Aptitude
- IJIP_V5_I5
- Horibe
- 09 Binary Trees
- Quantitative Business Analysis Sneak Preview
- Wagering with Zeno
- avltreefsds
- Binary Search Tree
- Data Structure and Algorithm Lab Manual
- Project
- lesson cycle template
- TreePlan 204 Example Mac
- Learning as Search

You are on page 1of 12

com

FINALTERM EXAMINATION

CS301- Data Structures

Question No: 1 ( Marks: 1 ) - Please coose one

__________ only removes items in reverse order as they were entered.

! "tack

! Queue

! Both of these

! None of these

Question No: # ( Marks: 1 ) - Please coose one

ere is a small function definition!

void f"int i# int $%&

'

i ( 1)

% ( *)

+

Su,,ose that a main ,ro-ram has two inte-er varia.les / and y# which are -iven the value 0.

0hen the main ,ro-ram calls f"/#y&) 1hat are the values of / and y after the function f finishes2

! Both / and y are still 0.

! / is now 1# .ut y is still 0.

! $ is still %& 'ut ( is no) #*

! / is now 1# and y is now *.

Question No: + ( Marks: 1 ) - Please coose one

Select the one FALSE statement a.out .inary trees!

! E,er( 'inar( tree as at least one no-e*

! 3very non-em,ty tree has e/actly one root node.

! 3very node has at most two children.

! 3very non-root node has e/actly one ,arent.

www.virtualinspire.com

Question No: . ( Marks: 1 ) - Please coose one

3very 456 is _________________

! Binary 0ree

! Com,lete Binary 0ree

! None of these

! /inar( "earc Tree

Question No: 0 ( Marks: 1 ) - Please coose one

Searchin- an element in an 456 tree ta%e ma/imum _______ time "where n is no. of nodes

in 456 tree&#

! 6o-*"n71&

! 6o-*"n71& -1

! 1*.. Lo1#n

! 1.88 6o-*n

Question No: 2 ( Marks: 1 ) - Please coose one

Su,,ose that we have im,lemented a priority queue .y storin- the items in a hea,. 1e are now

e/ecutin- a rehea,ification downward and the out-of-,lace node has ,riority of 9*. 0he node:s

,arent has a ,riority of ;*# the left child has ,riority <* and the node:s ri-ht child has ,riority 8*.

1hich statement .est descri.es the status of the rehea,ification.

! 0he rehea,ification is done.

! 0he ne/t ste, will interchan-e the two children of the out-of-,lace node.

www.virtualinspire.com

! 0he ne/t ste, will swa, the out-of-,lace node with its ,arent.

! 0he ne/t ste, will swa, the out-of-,lace node with its left child.

Question No: 3 ( Marks: 1 ) - Please coose one

Su,,ose you im,lement a hea, "with the lar-est element on to,& in an array. Consider the

different arrays .elow# determine the one that cannot ,ossi.ly .e a hea,!

! ; 8 < 9 3 * 1

! ; 3 8 * 1 9 <

! ; 8 9 3 < * 1

! 3 + 2 . # 0 1

Question No: 4 ( Marks: 1 ) - Please coose one

=f there are *3 e/ternal nodes in a .inary tree then what will .e the no. of internal nodes in this

.inary tree2

! *3

! *9

> *1

22

6esson ? *;"the num.er of internal nodes is N# the num.er of e/ternal nodes will .e N71.)

Question No: 5 ( Marks: 1 ) - Please coose one

=f there are N e/ternal nodes in a .inary tree then what will .e the no. of internal nodes in this

.inary tree2

! N -1

! N71

! N7*

www.virtualinspire.com

! N

Question No: 1% ( Marks: 1 ) - Please coose one

1hich one of the followin- is N@0 the ,ro,erty of eAuivalence relation!

! Befle/ive

! Symmetric

! 0ransitive

! Associati,e (lesson no +.)

Question No: 11 ( Marks: 1 ) - Please coose one

0he definition of 0ransitivity ,ro,erty is

! Cor all element / mem.er of S# / B /

! Cor all elements / and y# / B y if and only if y B /

! For all ele6ents $& ( an- 7& i8 $ R ( an- ( R 7 ten $ R 7 (lesson no +.)

! Cor all elements w# /# y and D# if / B y and w B D then / B D

Question No: 1# ( Marks: 1 ) - Please coose one

Enion is a _______ time o,eration.

! 9onstant ( lesson : +0 ;a1e 11)

! Folynomial

! 3/,onential

! None of the -iven o,tions

www.virtualinspire.com

Question No: 1+ ( Marks: 1 ) - Please coose one

1hich of the followin- is N@0 a correct statement a.out 0a.le 4D0.

! =n a ta.le# the ty,e of information in columns may .e different. yes

! A ta'le consists o8 se,eral colu6ns& kno)n as entities* "6esson ? 3G ,a-e 1 &

! 0he row of a ta.le is called a record.

! 4 maHor use of ta.le is in data.ases where we .uild and use ta.les for %ee,in-

information.

Correct 4 ta.le consists of several columns# %nown as fields.

Question No: 1. ( Marks: 1 ) - Please coose one

=n the worst case of deletion in 456 tree reAuires _________.

! @nly one rotation

! Botation at each non-leaf node

! Botation at each leaf node

! Rotations e<ual to lo1# N (lesson : #+)

Question No: 10 ( Marks: 1 ) - Please coose one

Binary Search is an al-orithm of searchin-# used with the ______ data.

! "orte- (lesson : +5)

! Ensorted

! etero-eneous

! Bandom

Question No: 12 ( Marks: 1 ) - Please coose one

www.virtualinspire.com

1hich of the followin- statement is correct2

! 4 0hreaded Binary 0ree is a .inary tree in which every node that does not have a left

child has a 0B34D "in actual sense# a lin%& to its =N@BD3B successor.

! 4 0hreaded Binary 0ree is a .inary tree in which every node that does not have a ri-ht

child has a 0B34D "in actual sense# a lin%& to its FB3@B3DB successor.

! A Trea-e- /inar( Tree is a 'inar( tree in )ic e,er( no-e tat -oes not a,e a

ri1t cil- as a T=REA> (in actual sense& a link) to its INOR>ER successor*

! 4 0hreaded Binary 0ree is a .inary tree in which every node that does not have a ri-ht

child has a 0B34D "in actual sense# a lin%& to its F@S0@BD3B successor.

Question No: 13 ( Marks: 1 ) - Please coose one

By usin- __________we avoid the recursive method of traversin- a 0ree# which ma%es use of

stac%s and consumes a lot of memory and time.

! Binary tree only

! Trea-e- 'inar( tree "lesson ? *; ,a-e 3&

! ea, data structure

! uffman encodin-

Question No: 14 ( Marks: 1 ) - Please coose one

1hich of the followin- statement is N@0 true a.out threaded .inary tree2

! Bi-ht thread of the ri-ht-most node ,oints to the dummy node.

! 6eft thread of the left-most node ,oints to the dummy node.

! 0he left ,ointer of dummy node ,oints to the root node of the tree.

! Le8t trea- o8 te ri1t-6ost no-e ;oints to te dummy no-e*

Lecture # 28 "The left pointer of this node is pointing to the root node of the tree while the ri-ht ,ointer is seen

,ointin- itself i.e. to dummy node. 0here is no ,ro.lem in doin- all these thin-s. 1e have ,ut the address of dummy

node in its ri-ht ,ointer and ,ointed the left thread of the left most node towards the dummy node. Similarly the ri-ht

thread of the ri-ht-most node is ,ointin- to the dummy node. Now we have some e/tra ,ointers whose hel, will

ma%e the nextnorder routine function ,ro,erly.I

www.virtualinspire.com

Question No: 15 ( Marks: 1 ) - Please coose one

Consider a min hea,# re,resented .y the followin- array!

11#**#33#99#<<

4fter insertin- a node with value 88.1hich of the followin- is the u,dated min hea,2

> 11#**#33#99#<<#88

! 11#**#33#99#88#<<

! 11#**#33#88#99#<<

! 11#**#88#33#99#<<

Question No: #% ( Marks: 1 ) - Please coose one

Consider a min hea,# re,resented .y the followin- array!

3#9#8#;#<

4fter callin- the function deleteJin"&.1hich of the followin- is the u,dated min hea,2

! 9#8#;#<

! 8#;#<#9

! .&0&2&3

! 9#8#<#;

Question No: #1 ( Marks: 1 ) - Please coose one

1e can .uild a hea, in ________ time.

! Linear (lecture : +% ;a1e 4)

! 3/,onential

! Folynomial

! None of the -iven o,tions

Question No: ## ( Marks: 1 ) - Please coose one

Su,,ose we are sortin- an array of ei-ht inte-ers usin- Auic% sort# and we have Hust finished the

first ,artitionin- with the array loo%in- li%e this!

* < 1 ; K 1* 11 10

www.virtualinspire.com

1hich statement is correct2

! Te ;i,ot coul- 'e eiter te 3 or te 5*

! Te ;i,ot coul- 'e te 3& 'ut it is not te 5*

! 0he ,ivot is not the ;# .ut it could .e the K

! Neither the ; nor the K is the ,ivot.

Question No: #+ ( Marks: 1 ) - Please coose one

1hich formula is the .est a,,ro/imation for the de,th of a hea, with n nodes2

! lo1 ('ase #) o8 n

! 0he num.er of di-its in n ".ase 10&# e.-.# 19< has three di-its

! 0he sAuare root of n

! n

Question No: #. ( Marks: 1 ) - Please coose one

Su,,ose you im,lement a Jin hea, "with the smallest element on to,& in an array. Consider the

different arrays .elow) determine the one that cannot ,ossi.ly .e a hea,!

! 18# 1G# *0# **# *9# *G# 30

! 18# *0# 1G# *9# **# 30# *G

! 18# *9# 1G# *G# 30# *0# **

! 12& #.& #%& +%& #4& 14& ##

Question No: #0 ( Marks: 1 ) - Please coose one

1hile Hoinin- nodes in the .uildin- of uffman encodin- tree if there are more nodes with same

freAuency# we choose the nodes _______.

! Ran-o6l(

! 0hat occur first in the te/t messa-e

! 0hat are le/ically smaller amon- others.

! 0hat are le/ically -reater amon- others

Question No: #2 ( Marks: 1 ) - Please coose one

Consider the followin- ,ara-ra,h with .lan%s.

4 LL.LL.. is a linear list where LLLLL and LLLL ta%e ,lace at the

www.virtualinspire.com

same end . 0his end is called the LL.LLL.

1hat would .e the correct fillin- the a.ove .lan% ,ositions2

! "i& Aueue "ii& insertion "iii& removals "iv& to,

! "i& stac% "ii& insertion "iii& removals "iv& .ottom

! (i) stack (ii) insertion (iii) re6o,als (i,) to;

! "i& tree "ii& insertion "iii& removals "iv& to,

Question No: #3 ( Marks: 1 ) - Please coose one

4 .inary tree with 33 internal nodes has _______ lin%s to internal nodes.

! 31

! +# (n-1 links to internal no-es)

! 33

! 88 "*n lin%s&

A binary tree with N internal nodes has N+1 external nodes.

Pro;ert(: A binary tree with N internal nodes has 2N links:

N-1 links to internal nodes and N+1 links to external nodes.

Question No: #4 ( Marks: 1 ) - Please coose one

1hich traversal -ives a decreasin- order of elements in a hea, where the ma/ element is stored

at the to,2

! ,ost-order

! level-order

! inorder

! None o8 te 1i,en o;tions

Question No: #5 ( Marks: 1 ) - Please coose one

1hat reAuirement is ,laced on an array# so that !inary search may .e used to locate an entry2

! 0he array elements must form a hea,.

! 0he array must have at least * entries.

! Te arra( 6ust 'e sorte-* (lecture : +4)

! 0he array:s siDe must .e a ,ower of two.

www.virtualinspire.com

Question No: +% ( Marks: 1 ) - Please coose one

1hich of the followin- is a non linear data structure2

! 6in%ed 6ist

! Stac%

! Queue

! Tree (lecture : 11 ;a1e .)

Question No: +1 ( Marks: 1 )

=f a Binary 0ree has N internal nodes what are the no. of e/ternal nodes in it.

Sol. 6esson ? *;"the num.er of internal nodes is N# the num.er of e/ternal nodes will .e N71.)

Question No: +# ( Marks: 1 )

1hat is meant .y Symmetry in eAuivalence relations2

Sol. Symmetry in eAuivalence relations mean for all elements / and y# / B y if and only if y B /

Question No: ++ ( Marks: # )

ow hea, sort wor%s to sort a set of data.

Question No: +. ( Marks: # )

ow we can a,,ly Cind o,eration on elements com.ined throu-h Enion o,eration.

Question No: +0 ( Marks: + )

ow we can use conce,t of eAuivalence relations to -enerate a JaDe.

www.virtualinspire.com

Question No: +2 ( Marks: + )

"u;;ose )e are sortin1 an arra( o8 ei1t inte1ers usin1 a so6e <ua-ratic sortin1 al1orit6*

A8ter 8our iterations o8 te al1orit6?s 6ain loo;& te arra( ele6ents are or-ere- as so)n

ere:

# . 0 3 4 1 + 2

@ic state6ent is correctA (Note: Our selectionsort ;icks lar1est ite6s 8irst*)

A* Te al1orit6 6i1t 'e eiter selectionsort or insertionsort*

/* Te al1orit6 6i1t 'e selectionsort& 'ut it is not insertionsort*

9* Te al1orit6 is not selectionsort& 'ut it 6i1t 'e insertionsort* (9orrect)

>* Te al1orit6 is neiter selectionsort nor insertionsort*

E* None o8 tese*

Question No: +3 ( Marks: + )

ow many leaf and non-leaf nodes are ,resent in a com,lete .inary tree if its de,th is ; 2

Solution!

6eaf nodes ( *M;(1*G

Non-leaf nodes (1*;

Question No: +4 ( Marks: 0 )

=f we insert a new element into an 456 tree of hei-ht 9# is one rotation sufficient to re-esta.lish

.alance2 Nustify your answer.

Question No: +5 ( Marks: 0 )

@rite -o)n te 9BB co-e 8ro6 "election "ort Al1orit6*

Question No: .% ( Marks: 1% )

Consider the followin- data!

te cat in te at

a& Build freAuency ta.le for the a.ove data.

.& Create a uffman tree to determine the .inary codes for each

character.

c& 1hat will .e the code of each letter2

a&

9aracter Fre<uenc(

c 1

i 1

n 1

e *

a *

h 3

t 9

s, 9

www.virtualinspire.com

c)

9aracter 9o-e

c 0000

i 0001

n 0010

e 0011

a 010

h 011

t 10

s, 11

Question No: .1 ( Marks: 1% )

Su,,ose we have .uild a S%i, list .Now we want to add and remove items from the list .Oive

4l-orithms for insert (ite6) and -elete (ite6) methods of the S%i, 6ist.

"olution:

1hen we are -oin- to insert "add& an item "x"#& into a s%i, list# we use a randomiDed al-orithm.

1e send the item in a ,air.

insert

0o insert an item "x# o& into a s%i, list# we use a randomiDed al-orithm!

P 1e re,eatedly toss a coin until we -et tails# and we denote with i the num.er of

times the coin came u, heads

P =f i h# we add to the s%i, list new lists Sh71# L # Si 71# each containin- only the

two s,ecial %eys

P 1e search for x in the s%i, list and find the ,ositions p0# p1 # L# pi of the items

with lar-est %ey less than x in each list S0# S1# L # Si

P Cor j 0# L# i# we insert item "x# o& into list Sj after ,osition pj

-elete

0o remove an item with %ey x from a s%i, list# we ,roceed as follows!

P 1e search for x in the s%i, list and find the ,ositions p0# p1 # L# pi of the items

with %ey x# where ,osition pj is in list Sj

P 1e remove ,ositions p0# p1 # L# pi from the lists S0# S1# L # Si

P 1e remove all .ut one list containin- only the two s,ecial %eys

- A Modified Recursive X-Y Cut Algorithm for Solving Block Ordering ProblemsUploaded byPhaisarn Sutheebanjard
- CS301SolvedMCQsUploaded byMuhammadRizwanIslamKhan
- SyllabusUploaded bylekhaperumal
- chatzikyriakidis-phdthesis-revised2.pdfUploaded byMartin Nicholas
- Computer Notes - Data Structures - 24Uploaded byecomputernotes
- GggUploaded bynannurah
- most_importantUploaded byapi-19746702
- AptitudeUploaded bynkshah25
- IJIP_V5_I5Uploaded byAI Coordinator - CSC Journals
- HoribeUploaded byΑλέξανδρος Γεωργίου
- 09 Binary TreesUploaded byIan Seepersad
- Quantitative Business Analysis Sneak PreviewUploaded byk_ij9658
- Wagering with ZenoUploaded byJeff Pratt
- avltreefsdsUploaded byapi-3759413
- Binary Search TreeUploaded byvsamr
- Data Structure and Algorithm Lab ManualUploaded byRaja Mala Harinika
- ProjectUploaded bySubhadeep Sinha Roy
- lesson cycle templateUploaded byapi-286827257
- TreePlan 204 Example MacUploaded byRonal Almestar
- Learning as SearchUploaded byKandarp Shroff
- Pickering Profunctor OpticsUploaded byTim Millar
- TreePlan 203 GuideUploaded byRomeo Anacan
- L5_AVLTreesUploaded byAziz
- final projectUploaded byapi-335343479
- Chen Main Josh iUploaded bybobster124u
- je25Uploaded bykracha82
- 2014-fpdaaUploaded byajitkarthik
- Practice Final CS61cUploaded byEdward Yixin Guo
- cs344-lect2-3-Astar-2012-1-3-5Uploaded byashu345
- ProblemSolving SearchUploaded byShruti Shru

- Weight Balanced Binary TreeUploaded byBODJE N'KAUH NATHAN-REGIS
- L13DSAUploaded byhargobindb
- Balanced Trees and Tree RotationsUploaded byMahdi MozafarMoghadam
- AVLUploaded byepanicu2000
- splay treeUploaded byEsther Grace Vinitha
- Priority Search TreesUploaded bymanishbhardwaj8131
- 08-splayUploaded byPavithraRam
- AVL-TreesUploaded byAswin Kumar
- AVL+B-Tree+TreapUploaded byb12817
- avl treeUploaded byshravi188
- MIT6_006F11_lec06Uploaded byximbica
- 04. Treaps_26014Uploaded byFabio Francisco
- Bab 5 - TreeUploaded byVijay Fathur
- Avl TreesUploaded bySoumyadeep Ghosh
- AVL treeUploaded byShiladitya Swarnakar
- Self Balancing Binary Search TreeUploaded bythe_swagmaster
- avl-treeUploaded bySuruttaiyan Suru
- AVL-Tree-Operation.pdfUploaded byRajContent
- Introduction-of-AVL-Tree.pdfUploaded byRajContent
- unit3-spUploaded byhrsli
- AVL Trees - Horowitz Sahni CPP - Lec43Uploaded byhailos
- Binary TreeUploaded byPawan Vaskar
- Splay TreesUploaded byEssirahc Lamigo
- AVL B Tree Treap SplayUploaded bySunil Kumar
- avl_treeUploaded byPapori Borgohain
- AvlUploaded byKashif Amjad
- AVL Tree NotesUploaded byMayank Singh
- AVL-Tree-Deletion.pdfUploaded byRajContent
- AVL treeUploaded byArockiaruby Ruby
- AVL TreeUploaded byMahdi Mashrur Matin