You are on page 1of 6

DS

ata Structures Aptitude


1. What is data structure?
A data structure is a way of organizing data that considers not only the items
stored, but also their relationship to each other. Advance knowledge about the
relationship between data items allows designing of efficient algorithms for the
manipulation of data.
2. List out the areas in which data structures are applied extensively?
Compiler Design, Operating System, Database anagement
System,
Statistical analysis package, !umerical Analysis,
"raphics, Artificial #ntelligence, Simulation
3. What are the major data structures used in the following areas : !"#$% &etwor'
data model ( )ierarchical data model.
$D%S & Array 'i.e. Array of structures(
!etwork data model & "raph
)ierarchical data model & *rees
*. +f you are using , language to implement the heterogeneous lin'ed list% what pointer
type will you use?
*he heterogeneous linked list contains different data types in its nodes and we
need a link, pointer to connect them. #t is not possible to use ordinary pointers for this. So
we go for void pointer. +oid pointer is capable of storing pointer to any type as it is a
generic pointer type.

-. #inimum num.er of /ueues needed to implement the priority /ueue?
*wo. One ,ueue is used for actual storing of data and another for storing
priorities.
0. What is the data structures used to perform recursion?
Stack. %ecause of its -#.O '-ast #n .irst Out( property it remembers its /caller0 so
knows whom to return when the function has to return. $ecursion makes use of system
stack for storing the return addresses of the function calls. 1very recursive function has
its e/uivalent iterative 2non3recursive4 function. 1ven when such e,uivalent iterative
procedures are written, e2plicit stack is to be used.
5. What are the notations used in 1valuation of 6rithmetic 1xpressions using prefix and
postfix forms?
3olish and $everse 3olish notations.
7. ,onvert the expression 226 8 "4 9 , : 2! : 14 ; 2< 8 =44 to e/uivalent >refix and
>ostfix notations.
3refi2 !otation4 5 6 7 8A%C 6 D1 8 ."
3ostfi2 !otation4 A% 8 C 7 D1 6 6 ." 8 5
?. $orting is not possi.le .y using which of the following methods?
2a4 +nsertion 2.4 $election 2c4 1xchange 2d4 !eletion
'd( Deletion.
9sing insertion we can perform insertion sort, using selection we can perform
selection sort, using e2change we can perform the bubble sort 'and other similar sorting
methods(. %ut no sorting method can be done :ust using deletion.
1@. 6 .inary tree with 2@ nodes has null .ranches?
;<
-et us take a tree with = nodes 'n>=(
#t will have only ? 'ie,=8<( null branches. #n general,
6 .inary tree with n nodes has exactly n+1 null nodes.
11. What are the methods availa.le in storing se/uential files ?
Straight merging, !atural merging,
3olyphase sort, Distribution of #nitial runs.
12. )ow many different trees are possi.le with 1@ nodes ?
<@<A
.or e2ample, consider a tree with B nodes'n>B(, it will have the ma2imum
combination of = different 'ie, ;
B
6 B > =( trees.
i ii iii iv v
!ull %ranches
#n general4
+f there are n nodes% there exist 2
n
-n different trees.
13. List out few of the 6pplication of tree data3structure?
*he manipulation of Arithmetic e2pression,
Symbol *able construction,
Synta2 analysis.
1*. List out few of the applications that ma'e use of #ultilin'ed $tructures?
Sparse matri2, #nde2 generation.
1-. +n tree construction which is the suita.le efficient data structure?
2a4 6rray 2.4 Lin'ed list 2c4 $tac' 2d4 Aueue 2e4 none
'b( -inked list
10. What is the type of the algorithm used in solving the 7 Aueens pro.lem?
%acktracking
15. +n an 6BL tree% at what condition the .alancing is to .e done?
#f the /pivotal value0 'or the /)eight factor0( is greater than < or less than &<.
17. What is the .uc'et siCe% when the overlapping and collision occur at same time?
One. #f there is only one entry possible in the bucket, when the collision occurs,
there is no way to accommodate the colliding value. *his results in the overlapping of
values.
1?. Draverse the given tree using +norder% >reorder and >ostorder traversals.
A
% C
D
1 . "
) #
C
"iven tree4
#norder 4 D ) % 1 A . C # " C
3reorder4 A % D ) 1 C . " # C
3ostorder4 ) D 1 % . # C " C A
2@. Dhere are 7% 1-% 13% 1* nodes were there in * different trees. Which of them could
have formed a full .inary tree?
<=.
#n general4
Dhere are 2
n
-1 nodes in a full .inary tree.
"y the method of elimination:
.ull binary trees contain odd number of nodes. So there cannot be full
binary trees with D or <A nodes, so re:ected. Eith <B nodes you can form a complete
binary tree but not a full binary tree. So the correct answer is <=.
Note:
.ull and Complete binary trees are different. 6ll full .inary trees are complete
.inary trees .ut not vice versa.
21. +n the given .inary tree% using array you can store the node * at which location?
< ; B 6 6 A 6 6 =
$oot -C< $C< -C; $C; -CB $CB -CA $CA
where -Cn means -eft Child of node n and $Cn means $ight Child of node n
<
; B
A
=
22. $ort the given values using Auic' $ort?
?= F@ F= D@ D= ?@ == =@ A=
Sorting takes place from the pivot value, which is the first value of the given
elements, this is marked bold. *he values at the left pointer and right pointer are indicated
using
-
and
$
respectively.
65 F@
-
F= D@ D= ?@ == =@ A=
$
Since pivot is not yet changed the same process is continued after interchanging the
values at
-
and
$
positions
65 A= F=
-
D@ D= ?@ == =@
$
F@
65 A= =@ D@
-
D= ?@ ==
$
F= F@
65 A= =@ == D=
-
?@
$
D@ F= F@
65 A= =@ == ?@
$
D=
-
D@ F= F@
Ehen the - and $ pointers cross each other the pivot value is interchanged with the value
at right pointer. #f the pivot is changed it means that the pivot has occupied its original
position in the sorted order 'shown in bold italics( and hence two different arrays are
formed, one from start of the original array to the pivot position6< and the other from
pivot position8< to end.
60
-
A= =@ ==
$
65 85
-
D@ F= F@
$
55
-
A= =@
$
60 65 70
$
D@
-
F= 85
50
-
A=
$
55 60 65 70 D@
-
F=
$
85
#n the ne2t pass we get the sorted form of the array.
45 50 55 60 65 70 75 80 85

You might also like