44 views

Uploaded by RizwanIlyas

cs 301

- Brainy Business
- cs301
- cs301MCQSBYMOAZ
- ADS UNIT-1 PPT
- Types and Opetopes
- Cs2201 Data Structures
- A Pascal Quicksort
- (1993) N.nievergelt, K.H. Hinrichs - Algorithms and Data Structures With Applications to Graphics and Geometry
- Quiz2.sp10
- Finalsol Sample[1]
- Bubble sort
- Lesson Plan C#.Net
- Data Structures and Algorithms in C++ oleh Krisna Adiyarta
- TMC1433_1434-Assignment02 2014
- C1
- JOB Questions Experiences
- M.E DataStructure Unit3 Two Marks
- Menu Makan Siang Pak Direktur
- APS Lect 9 Segment Tree
- Cse102 Data-structures-And-Algorithms Eth 2.00 Ac29

You are on page 1of 14

com

FINALTERM EXAMINATION

CS301- Data Structures

Question No: 1 Mar!s: 1 " # $lease c%oose one

The arguments passed to a function should match in number, type and order with the

parameters in the function definition.

True

& !alse

Question No: ' Mar!s: 1 " # $lease c%oose one

"f numbers #, $$$, %, %& are inserted in a 'ueue, which one will be remo(ed first)

& %&

& %

& $$$

#

Question No: ( Mar!s: 1 " # $lease c%oose one

Suppose current*ode refers to a node in a lin+ed list ,using the *ode class with member

(ariables called data and ne-t*ode.. /hat statement changes current*ode so that it refers

to the ne-t node)

& current*ode 001

& current*ode 2 ne-t*ode1

& current*ode 02 ne-t*ode1

& current*ode 2 current*ode-3ne-t*ode1

Question No: ) Mar!s: 1 " # $lease c%oose one

4 *ompoun+ ,ata -tructure is the data structure which can ha(e multiple data

items of same type or of different types. /hich of the following can be considered

compound data structure)

& 4rrays

5in+5ists

& 6inary Search Trees

& 4ll of the gi(en options

www.virtualinspire.com

Question No: . Mar!s: 1 " # $lease c%oose one

7ere is a small function definition8

void f(int i, int &k)

{

i = 1;

k = 2;

}

Suppose that a main program has two integer (ariables x and y, which are gi(en the

(alue 0. Then the main program calls f(x,y); /hat are the (alues of x and y after

the function f finishes)

& 6oth x and y are still 0.

& x is now 1, but y is still 0.

x is still 0, but y is now $.

& x is now 1, and y is now $.

Question No: / Mar!s: 1 " # $lease c%oose one

The difference between a binary tree and a binary search tree is that ,

& a binary search tree has two children per node whereas a binary tree can ha(e

none, one, or two children per node

& in binary search tree nodes are inserted based on the (alues they contain

& in binary tree nodes are inserted based on the (alues they contain

& none of these

Question No: 0 Mar!s: 1 " # $lease c%oose one

Compiler uses which one of the following to e(aluate a mathematical e'uation,

& 6inary Tree

www.virtualinspire.com

& 6inary Search Tree

& $arse Tree

& 495 Tree

Question No: 1 Mar!s: 1 " # $lease c%oose one

"f there are #: internal nodes in a binary tree then how many e-ternal nodes this binary

tree will ha(e)

& #%

& ..

& #:

& #;

Question No: 2 Mar!s: 1 " # $lease c%oose one

"f there are $3 e-ternal nodes in a binary tree then what will be the no. of internal nodes

in this binary tree)

& $3

& $%

& $1

$$

Question No: 13 Mar!s: 1 " # $lease c%oose one

/hich of the following method is helpful in creating the heap at once)

& insert

& add

& update

preculateDown ,lecture <31 page 1.

Question No: 11 Mar!s: 1 " # $lease c%oose one

The defnition of Transitivity property is

& For all element x member of S, x R x

& For all elements x and y, x R y if and only if y R x

For all elements x, y and z, if x R y and y R z then x R z

& For all elements w, x, y and z, if x R y and w R z then x R z

Question No: 1' Mar!s: 1 " # $lease c%oose one

4 binary tree of * nodes has =======.

www.virtualinspire.com

& 5og10 * le(els

& Lo4' N levels

& * > $ le(els

& * - $ le(els

Question No: 1( Mar!s: 1 " # $lease c%oose one

"f there are * elements in an array then the number of ma-imum steps needed to find an

element using 6inary Search is ======= .

*

*

$

*log$*

lo4'N

Question No: 1) Mar!s: 1 " # $lease c%oose one

Consider te following array

$3 1# # 1$ %0 10 ;

4fter the first pass of a particular algorithm, the array loo+s li+e

1# # 1$ $3 10 ; %0

*ame the algorithm used

7eap sort

& Selection sort

& "nsertion sort

& 5u66le sort

Question No: 1. Mar!s: 1 " # $lease c%oose one

"f both pointers of the node in a binary tree are *?55 then it will be a>an ======= .

& "nner node

5eaf node

& @oot node

& *one of the gi(en options

Question No: 1/ Mar!s: 1 " # $lease c%oose one

6y using ==========we a(oid the recursi(e method of tra(ersing a Tree, which ma+es

use of stac+s and consumes a lot of memory and time.

& 6inary tree only

Threaded binary tree

www.virtualinspire.com

& 7eap data structure

& 7uffman encoding

Question No: 10 Mar!s: 1 " # $lease c%oose one

4 complete binary tree of height 3 has between ======== nodes.

& & to 1%

& to 1#

& & to 1:

& & to 1;

Question No: 11 Mar!s: 1 " # $lease c%oose one

Consider a min heap, represented by the following array8

3,%,:,;,#,10

4fter inserting a node with (alue 1./hich of the following is the updated min heap)

& 3,%,:,;,#,10,1

& 3,%,:,;,#,1,10

& 3,%,1,#,;,10,:

& 17)7(7.707137/ close to correct 6ut correct ans is 17)7(707.7137/

Question No: 12 Mar!s: 1 " # $lease c%oose one

Consider a min heap, represented by the following array8

10,30,$0,;0,%0,#0,&0,:0

4fter inserting a node with (alue 31./hich of the following is the updated min heap)

& 137(37'37(17)37.37137/3703

& 10,30,$0,;0,%0,#0,&0,:0,31

& 10,31,$0,30,%0,#0,&0,:0,31

& 31,10,30,$0,;0,%0,#0,&0,:0

Question No: '3 Mar!s: 1 " # $lease c%oose one

/hich one of the following algorithms is most widely used due to its good a(erage time,

& 6ubble Sort

& "nsertion Sort

& Quic! -ort

www.virtualinspire.com

& Aerge Sort

Question No: '1 Mar!s: 1 " # $lease c%oose one

Which of the following statement is correct about fndx! operation"

& 4 find,-. on element - is performed by returning e-actly the same node that is

found.

& A 8in+9" on element 9 is per8orme+ 6: returnin4 t%e root o8 t%e tree

containin4 9.

& 4 find,-. on element - is performed by returning the whole tree itself containing

-.

& 4 find,-. on element - is performed by returning T@?B.

Question No: '' Mar!s: 1 " # $lease c%oose one

/hich of the following statement is *CT correct about find operation8

& "t is not a re'uirement that a find operation returns any specific name, Dust that

finds on two elements return the same answer if and only if they are in the same set.

& Cne idea might be to use a tree to represent each set, since each element in a tree

has the same root, thus the root can be used to name the set.

& "nitially each set contains one element.

& Initiall: eac% set contains one element an+ it +oes not ma!e sense to ma!e a

tree o8 one no+e onl:.

Question No: '( Mar!s: 1 " # $lease c%oose one

The following are statements related to 'ueues.

,i. The last item to be added to a 'ueue is the first item to be remo(ed !alse

statement

,ii.4 'ueue is a structure in which both ends are not used !alse statement

,iii.The last element hasnEt to wait until all elements preceding it on the 'ueue are remo(ed !alse

statement

www.virtualinspire.com

,i(. A queue is said to be a last-in-first-out list or LIFO data structure. !alse statement

/hich of the abo(e is>are related to normal 'ueues)

& ,iii. and ,ii. only

& ,i., ,ii. and ,i(. only

& ,ii. and ,i(. only

*one of the gi(en options

Question No: ') Mar!s: 1 " # $lease c%oose one

The ma-imum number of e-ternal nodes ,lea(es. for a binary tree of height 7 is

;;;;;;;;;

& 2

H

& #

$

%&

& #

$

'&

& #

$

%#

Question No: '. Mar!s: 1 " # $lease c%oose one

"n complete binary tree the bottom le(el is filled from ========

& 5eft to right

& @ight to left

& *ot filled at all

& *one of the gi(en options

Question No: '/ Mar!s: 1 " # $lease c%oose one

/e are gi(en * items to build a heap , this can be done with ===== successi(e inserts.

& *-1

& N

& *01

& *F$

Question No: '0 Mar!s: 1 " # $lease c%oose one

www.virtualinspire.com

Suppose we had a hash table whose hash function is Gn H 1$I, if the number 3# is

already in the hash table, which of the following numbers would cause a collision)

& 1%%

& 1%#

& 1%3

& 1%&

Question No: '1 Mar!s: 1 " # $lease c%oose one

7ere is an array of ten integers8

# 3 & J 1 ; 0 $ : %

The array after the !"@ST iteration of the large loop in a selection sort ,sorting from

smallest to largest..

& 3 ( 1 2 1 0 . ' / )

& $ : % 0 3 & J 1 ; #

& $ : % J 1 ; 0 3 & #

& 0 3 & $ : % J 1 ; #

Question No: '2 Mar!s: 1 " # $lease c%oose one

/hat re'uirement is placed on an array, so that binary search may be used to locate an

entry) & The array elements must form a heap.

& The array must ha(e at least $ entries.

& T%e arra: must 6e sorte+.

& The arrayEs siKe must be a power of two.

www.virtualinspire.com

Question No: (3 Mar!s: 1 " # $lease c%oose one

"n case of deleting a node from 495 tree, rotation could be prolong to the root node.

& Les

& No

Question No: (1 Mar!s: 1 "

"n merge sort do we need to ha(e e-tra memory, Dustify your answer in either

case.

Les we need e-tra memory in merge sort.

Question No: (' Mar!s: 1 "

/here is "norder Mredecessor of a non leaf node is present in a 6inary Search

Tree)

Question No: (( Mar!s: ' "

7ow we can search an element in S+ip 5ist.

Question No: () Mar!s: ' "

/hat is the drawbac+ of using arrays to store 6inary Search Trees.

www.virtualinspire.com

Question No: (. Mar!s: ( "

Calculate the codes of the following characters in table below using the hoffman

encoding tree,

character Code

*5 10000

SM 1111

o 001

b 0100

i 0101

r 110

Question No: (/ Mar!s: ( "

www.virtualinspire.com

N!or smaller lists, linear insertion sort performs well, but for larger lists, 'uic+ sort is

suitable to apply.N Oustify why)

Question No: (0 Mar!s: ( "

-uppose t%at we %ave implemente+ a priorit: <ueue 6: storin4 t%e items in a %eap.

=e are now e9ecutin4 a re%eapi8ication +ownwar+ an+ t%e out#o8#place no+e %as

priorit: o8 )'. T%e no+e>s parent %as a priorit: o8 0'7 t%e le8t c%il+ %as priorit: .'

an+ t%e no+e>s ri4%t c%il+ %as priorit: /'. =%ic% statement 6est +escri6es t%e status

o8 t%e re%eapi8ication.

A. T%e re%eapi8ication is +one.

5. T%e ne9t step will swap t%e out#o8#place no+e wit% its parent.

*. T%e ne9t step will swap t%e out#o8#place no+e wit% its le8t c%il+.

,. T%e ne9t step will swap t%e out#o8#place no+e wit% its ri4%t c%il+.

E. None o8 t%ese.

Question No: (1 Mar!s: . "

?ive two +i88erent reasons to e9plain w%: t%e 8ollowin4 6inar: tree is not a %eap:

Question No: (2 Mar!s: . "

7ere is an array of ten integers8

# 3 & J 1 ; 0 $ : %

Sort the array by using selection sort algorithm and show content of array after each step.

www.virtualinspire.com

. ( 1 2 1 0 3 ' / )

www.virtualinspire.com

-TE$ 1

3 ( 1 2 1 0 . ' / )

-TE$ '

3 1 1 2 ( 0 . ' / )

-TE$(

3 1 ' 2 ( 0 . 1 / )

-TE$ )

3 1 ' ( 2 0 . 1 / )

-TE$.

3 1 ' ( ) 0 . 1 / 2

-TE$/

3 1 ' ( ) . 0 1 / 2

-TE$ 0

3 1 ' ( ) . / 1 0 2

-TE$1

3 1 ' ( ) . / 0 1 2

3 1 ' ( ) . / 0 1 2

Question No: )3 Mar!s: 13 "

A lon4 se<uence o8 vowels nee+s to 6e transmitte+ e88icientl: so a pro4rammer

+eci+es to use @u88man enco+in4 to enco+e t%e vowels. A +istri6ution count stu+: o8

t:pical +ata :iel+e+ t%e 8ollowin4 8re<uenc: ta6le.

Fre<uenc: Ta6le

c%aracter 8re<uenc: @u88man co+e

A ((201 ; ; ; ; ; ; ;

E '3/0/ ; ; ; ; ; ; ;

I 1.11) ; ; ; ; ; ; ;

O '1..' ; ; ; ; ; ; ;

A 13(') ; ; ; ; ; ; ;

B )20. ; ; ; ; ; ; ;

A" *reate a @u88man tree to +etermine t%e 6inar: co+es 8or eac% c%aracter.

5" Fill t%e co+es into t%e ta6le a6ove.

*" Enco+e t%e 8ollowin4 se<uence EIBOAA

Question No: )1 Mar!s: 13 "

Consider the following tree.

a. Show that either it is a heap or not.

b. "f it is a heap then what type of heap is it)

c. 4dd %0 in the heap and con(ert it in ma- heap.

www.virtualinspire.com

- Brainy BusinessUploaded byNinyo Laurence
- cs301Uploaded byRizwanIlyas
- cs301MCQSBYMOAZUploaded byMuhammad Rameez Khalid
- ADS UNIT-1 PPTUploaded byVelumani Balakrishnan
- Types and OpetopesUploaded byaaabbbzak
- Cs2201 Data StructuresUploaded byKarthik Sara M
- A Pascal QuicksortUploaded byDesmond Mazoe
- (1993) N.nievergelt, K.H. Hinrichs - Algorithms and Data Structures With Applications to Graphics and GeometryUploaded byPadureanu Andrei
- Quiz2.sp10Uploaded byJoe Park
- Finalsol Sample[1]Uploaded byGobara Dhan
- Bubble sortUploaded byJunaid khan
- Lesson Plan C#.NetUploaded byManikandan Muthaiyan
- Data Structures and Algorithms in C++ oleh Krisna AdiyartaUploaded byindra nugroho
- TMC1433_1434-Assignment02 2014Uploaded byBang Din
- C1Uploaded byAttique Ur Rehman
- JOB Questions ExperiencesUploaded byVyom Rastogi
- Menu Makan Siang Pak DirekturUploaded bySarah Compton
- M.E DataStructure Unit3 Two MarksUploaded byArockiaruby Ruby
- APS Lect 9 Segment TreeUploaded byShivang Agrawal
- Cse102 Data-structures-And-Algorithms Eth 2.00 Ac29Uploaded bynetgalaxy2010
- Bubble SortUploaded byDivyaPatel
- Course Description ADSUploaded byRahul Jain
- 7Uploaded byMangat Singh
- How to Prepare for an interviewUploaded byRahul Sharma
- qar - Copy (2).txtUploaded byanto
- _DS NotesUploaded byniharika
- Priority QueuesUploaded byVivekGarg
- 10.1.1.53Uploaded byNaresh Chow
- 14018 Redblack TreeUploaded byprablpu
- Wakeup SchedulingUploaded byprecila

- 9702_Cherry-g84-4400.pdfUploaded byboba78
- Routing by MohandUploaded byMorad Alabsy
- 021716 Industrial Mems WebcastUploaded bymarksak
- BWSR Clean Water PresentationUploaded byMinnesota Senate Environment and Energy Committee
- Boi ProjectUploaded bynitin0010
- PVP 2010Uploaded byGilberto Jarvio
- Automatic Creation of PO in SAPUploaded byVishnu Kumar S
- 10.pdf murtadha ahmedUploaded byMurtadha Ahmed
- D6334Uploaded byrimi7al
- A Strategic Location Model of Stationary Production Units: A Case study in the Albacora Leste fieldUploaded byIJAERS JOURNAL
- Legal EthicsUploaded byA Lee Budaden
- Book PchUploaded byjbusowicz
- 19449564 Toyota MotorsUploaded byGagan Sandhu
- DPH-150S DPH-150SE UserManual V3.00.pdfUploaded bytol_iwan
- R5F364AEDFAUploaded byJulio Chuquilin Becerra
- Hierarchies in WebiUploaded byuday_bvh
- Sample DBQ - American RevolutionUploaded byjohnny131
- Microprocessor Book by B RamUploaded byAmal Living Miracle
- Performance ReviewUploaded byImran Malik
- Mind on Statistics Ch14 QUploaded byglenlcy
- How to Build a Reinforced Besser Block Retaining WallUploaded bycdorian
- Image Processing Methods for Evaluating Infrared ThermographicUploaded byJack Alvyn
- Online Motor Vehicle Licensing SystemUploaded bypsalmistme
- Mth301 Solved 2010Uploaded byamir10227866
- Anderson v American Rest GrpUploaded byBrian Wassom
- Tire Multi Axial Nut SetterUploaded byAnonymous kw8Yrp0R5r
- Funa v CSCUploaded byFAtty. LD
- Richard C. Crepeau - NFL FootballUploaded byTibor Krepli
- Confirmation letter Mr. V.pdfUploaded byAntox Lumajang
- CS0413 Vlsi and Embedded System DesignUploaded byImad A Shaheen