2017 Summer Model Answer Paper
2017 Summer Model Answer Paper
2017 Summer Model Answer Paper
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
Important Instructions to examiners:
1) The answers should be examined by key words and not as word-to-word as given in themodel answer
scheme.
2) The model answer and the answer written by candidate may vary but the examiner may tryto assess the
understanding level of the candidate.
3) The language errors such as grammatical, spelling errors should not be given moreImportance (Not
applicable for subject English and Communication Skills.
4) While assessing figures, examiner may give credit for principal components indicated in thefigure. The
figures drawn by candidate and model answer may vary. The examiner may give credit for anyequivalent
figure drawn.
5) Credits may be given step wise for numerical problems. In some cases, the assumed constantvalues may
vary and there may be some difference in the candidate’s answers and model answer.
6) In case of some questions credit may be given by judgement on part of examiner of relevant answer based
on candidate’s understanding.
7) For programming language papers, credit may be given to any other program based on equivalent concept.
Ans: Complexity: The complexity of an algorithm is a measure that describes its efficiency in (Definition:
terms of amount of time and space required for an algorithm to process. 1mark,
Classificatio
Classification: n: 1mark)
1. Time complexity
2. Space complexity
b) State limitations of the Big ‘O’notation. 2M
Ans: 1. Many algorithms are too hard to analyze mathematically. (Any two
points: 1
2. There may not be sufficient information to calculate the behavior of the algorithm in
Mark each)
the average case.
3. Big-Oh analysis only tells us how the algorithm grows with the size of the problem,
not how efficient it is, as it does not consider programming effort.
c) Define searching and enlist its types. 2M
Ans: Searching: It is the process of finding a data element in the given data structure. (Definition:1
Types: mark,
1. Linear search types:1/2
2. Binary search mark each)
Page | 1
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
d) Stack is linear data structure. Yes/No? Justify your answer. 2M
Ans: (Proper
sketch
representatio
n: 2 marks)
Ans: Linked list: It is linear collection of data elements. Each element in linked list is called as (Definition: 1
‘node’. Each node contains two fields. First is INFO which stores data & second is NEXT mark,
which is linked with address of next node in a list. Example: 1
mark)
Example:
Page | 2
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
Root Node In tree there is exactly one root In graph there is no such concept
node and every child have only of root node.
one parent.
Parent In trees, there is parent child In Graph there is no such parent
child relationship so flow can be there child relationship.
relationshi with direction top to bottom or
p vice versa.
Different Different types of trees are: There are mainly two types of
Types Binary Tree, Binary Search Tree, Graphs: Directed and Undirected
AVL tree, Heaps. graphs.
Applicatio Tree applications: sorting and Graph applications : Coloring of
ns searching like Tree Traversal & maps, in OR (PERT & CPM),
Binary Search. algorithms, Graph coloring, job
scheduling, etc.
Model Tree is a hierarchical model. Graph is a network model.
Ans: Indegree of node:It is number of edges coming towards a specified node i.e. number of (Indegree : 1
edges that have that specified node as the head. mark,
Outdegree: 1
Outdegree of node: It is number of edged going out from a specified node i.e. number of mark)
edges that have that specified node as the tail.
Page | 3
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
Example:
Ans: A binary tree is said to be binary search tree when all nodes less than the root node are (Binary
placed at the left of root node and all nodes greater than or equal to the root node are search Tree
placed at the right of root node.The nodes in the binary search tree are ordered. The time Concept: 2
needed to search an element from the tree is reduced. Binary search tree also speed up the marks,
insertion and deletion operation. Example: 2
marks)
Example:
1
0
5 1
9
1 6 1
7
In the above example, binary tree is a binary search tree. Its root node is 10. Nodes 5,1
and 6 are less than root node so they are placed at left and nodes 19,17 are greater than
root node so they are placed at right of node 10.In each level, root node is compared with
its child nodes before placing child nodes in a binary search tree.
c) What are the applications of graph? Explain any two with example. 4M
b) Convert following expression into postfix form with illustration of all steps. 4M
A+B C * (D/E) – F%G
Note: indicates exponent operator.
Ans: (Correct
Sr No Symbol Scanned Stack Expression Answer: 4
marks)
1 A A
2 + + A
3 B + AB
4 ↑ +↑ AB
5 C +↑ ABC
6 * +* ABC↑
7 ( +*( ABC↑
8 D +*( ABC↑ D
9 / +*(/ ABC↑ D
10 E +*(/ ABC↑ D E
11 ) +* ABC↑ D E/
12 - - ABC↑ D E/*+
Page | 6
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
13 F - ABC↑ D E/*+F
14 % -% ABC↑ D E/*+F
15 G -% ABC↑ D E/*+FG
16 ABC↑DE/*+FG%-
Postfix Expression: ABC↑DE/*+FG%-
c) Differentiate between stack and Queue.( Min. 4 points). 4M
Ans: (Representat
ion of linear
linked list:1
mark,
circular
Linked list:1
Fig: Linear Linked List ½
marks,doubl
y linked list:
:1 ½ marks)
Page | 7
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
Example:
Page | 8
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
f) Explain representation of graph in detail. 4M
Ans: Graph is a data structure that consists of following two components: ( Array
representatio
n: 2 marks,
linked
representatio
n: 2 marks )
2. Adjacency List: An array of linked lists is used. Size of the array is equal to number
of vertices. Let the array be array[]. An entry array[i] represents the linked list of vertices
adjacent to the ith vertex. This representation can also be used to represent a weighted
graph. The weights of edges can be stored in nodes of linked lists.
Adjacency list contains two columns as vertex name and adjacent vertices. It show who
all are adjacent vertices of each vertex in a graph.
Page | 9
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
a) Describe time and space trade off and time and space complexity with example of 4M
each.
Ans: Time and Space trade off: If we increase the space require to store data then time require (Time and
for processing will be less and if we decrease the space require to store data then time space trade
require for processing will be more. This phenomena is known as time – space trade off. off 2 marks;
Time Complexity: Time complexity of program / algorithm is the amount of computer Time
time that is required to run to completion. complexity 1
Example: mark; Space
Algorithm : for a=1 to n Complexity 1
a=a+1 mark)
loop
Time complexity of an algorithm with above statement requires n seconds O(n) as the key
statement executes n times.
Page | 10
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
Page | 11
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
2) PUSH: The process of adding new element to the top of the stack is called PUSH
operation. Push operation increments stack top by one and then adds new elements
into the array location indicated by stack top.
3) POP: The process of deleting an element from top of the stack is called POP operation.
Pop operation decrements stack top by one to delete an element from stack.
4) Retrieval & Display: Reading elements from stack and display them. The elements
from stack are displayed from 0th location of array upto the stack top position.
d) Describe priority queue with its advantages. 4M
Ans: A priority Queue is a collection of elements where each element is assigned a priority and (Description
the order in which elements are added into the queue. 2 marks;
The rules for processing the elements of priority queue are: Any 2
1) An element with higher priority is processed before any element of lower priority. Advantages:
2) Two elements with the same priority are processed according to the order in which 2 marks)
they are added to the queue (FCFS).
Page | 12
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
Advantages:
1) Preferences to the higher priority process are added at the beginning. High priority
process executes first.
2) Keep the list sorted in increasing order.
e) Write an algorithm for searching a node in linked list. 4M
2 8
7 9
Postorder traversal:-
2 6 7 9 8 5 15 10
Page | 13
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
4. Attempt any four : 16 Marks
a) Elaborate the steps for performing insertion sort for given elements of array. 4M
30 10 40 50 20 45
Iteration 2:
Now it will check for third element; It will first checks 40 with first element that is 10
which is less than 40; then it will check 40 with 30 and concludes that 30 is lesser than 40
so eventually it finds that 40 is already in its desirable location so 40 will be added to sub
list.
10 30 40 50 20 45
Iteration 3:
In Iteration 3 it will check for fourth element which is 50 which will be compare with 10;
it finds that 10 is smaller than 50, then it will check next element is sub list, which is 30,
this new element is again smaller than 50, so it will consider next element for comparison
which is 40. This element is also smaller so it will keep 50 to its place.
10 30 40 50 20 45
Iteration 4:
Next it will check for fifth element which is 20 with first element which is 10 so it will
jump to next location. At location two it will check with the element 30 with 20 which is
greater than 20. So it will shift all elements 30 onwards by one position and inserts 20 at
desired location.
10 30 40 50 20 45
→ → → →
10 20 30 40 50 45
Page | 14
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
Iteration 5:
Now it will check for sixth element which is 45 it is observed as greater than 10 so it will
consider next element for comparison which is 20. After comparison with 20 it will
compute that 20 is smaller than 45 and hence at its appropriate place. Further it will select
next location’s element for comparison which is 30, this element is also smaller than 45
hence next element will be selected. After comparing next element which is 40 and smaller
than 45 last element will be consider. The last element which is 50 and also greater than
45 will be shifted by one place and will give list in sorted order.
10 20 30 40 50 45
→ →
10 20 30 40 45 50
Sorted List
10 20 30 40 45 50
In the above diagram, first column shows result of push operation after each recursive call
execution. Remaining columns shows result of pop operation for calculating factorial.
After the last recursive call one by one values are removed from stack till stack becomes
empty.
c) Describe the stack as an abstract datatype. 4M
Ans: (**Note:Any representation of an ADT containing elements and operation shall be (Description:
considered**) 4 marks)
An Abstract Data type is one where we can store elements and also perform certain
operation on those elements. Stack provides such facilities. Stack as an abstract data type
contains stack elements such as array(list), stack top and its operations such as
initialize,isempty,isfull,push,pop,display.
Stack elements: array(list), stack top
Stack operations:
Initialize stack to be empty
Checking whether stack is empty or not
Checking if stack is full or not
If stack is not full, then insert a new element. This operation is called as push.
If stack in not empty, then retrieve element from stack top.
If stack in not empty, then remove an element from stack top. This operation is called
as pop.
Page | 16
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
d) Compare circular queue and double-ended queue. ( Min. 4 points) 4M
e) Define : 4M
i)Sibling
ii)Depth of tree
iii)Complete binary tree
iv)Degree of tree.
Ans: 1. Sibling: Sibling is defined as any nodes that have the same parent node. (Each
Definition:1
2. Depth of tree: Maximum number of levels in a tree is known as depth of a tree. mark)
3. Complete binary tree: A binary tree in which every non leaf node has exactly two
children and all leaf nodes are at same level is called complete binary tree.
4. Degree of tree: Degree of tree is defined as maximum number of child nodes of any
node. Or degree of node is the number of nodes connected to a particular node.
f) Explain Hashing with its significance. 4M
Ans: Hashing is the process of mapping large amount of data item to a smaller table with the (Description:
help of hashing function. The essence of hashing is to facilitate the next level of searching. 2 marks;
Hashing is a process where we use a hashing function that converts range of key values Significance:
2 marks)
Page | 17
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
into a range of indexes of an array. The value which is generated by hash function isuse
to store a value in hash table.
Significance of Hashing:
It is efficient to handle vast amount of data items in a given collection.
No extra space is required to store the index as in the case of other data structures.
A hash table provides fast data access and rapid updates.
Due to hashing process, the result is a hash data structure that can store or retrieve data
item in an average time disregard to the collection size.
a) Write a program for linear search. Find position of element 30 using linear search 8M
algorithm in given sequence.
10 5 20 25 8 30 40
Ans; #include<stdio.h>
(Correct
#include<conio.h>
void main() program:4
{ marks, (any
int a[20],i,x,n; other logic
clrscr(); shall also be
printf(“How many elements?”); considered)
scanf(“%d”,&n);
printf(“Enter array elements:n”);
for(i=0;i<n;i++)
scanf(“%d”,&a[i]);
printf(“nEnter element to search:”);
scanf(“%d”,&x);
for(i=0;i<n;i++)
if(a[i]==x)
break;
if(i<n)
printf(“Element found at index %d”,i);
else
printf(“Element not found”);
getch();
}
Steps to find position of element 30
Index 0 1 2 3 4 5 6
array A 10 5 20 25 8 30 40
Page | 18
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
Search 30
Ans: (List of
Following aretheapplications ofstack
application:
Depth first search of graph 2 marks, any
three
Expressionconversion&evaluation applications
Reversinga list with
Example: 2
Recursion marks Each)
Interrupt handling
Stackmachine
Matchingparenthesis in an expression
1. DepthFirstSearch (DFS)stack is used in searching method to store the values of
variables during execution of application.
Example:-
Page | 19
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
NotethatonlyCispushedontothestack,sincetheotherneighbor,EisnotpushedbecauseE
has alreadybeen pushedonto the stack).
e) Pop andprint the topelement Cand then push onto the stackall the
neighbors of CPrintC STACK D,E, F
f) Pop andprint the
top
elementFPrintFS
TACK D, E
NotethatonlyneighborDofFisnotpushedontothestack,sinceDhasalreadybeenpushedont
o the stack.
g) Pop andprint the topelement E and push onto the stackall the
Page | 20
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
neighbors ofDPrint E STACK:D,
h) Pop andprint the topelement D, and push onto the stackall the
neighbors ofDPrint D STACK : empty
Thestackisnowempty,sotheDFSofGstartingatJisnowcomplete.Accordingly,thenodes
which wereprinted,
J, K,G, C,F, E, D
These arethe nodesreachablefromJ.
2. Polish notation:- stack is used to process polish notations in the form of infix,
prefix and postfix notations. Operands and operators are stored inside the stack
while conversion and evaluation of mathematical expressions.
1 Empty ((A+B)*D)^(E-F) -
2 ( (A+B)*D)^(E-F) -
3 (( A+B)*D)^(E-F) -
4 (( +B)*D)^(E-F) A
5 ((+ B)*D)^(E-F) A
6 ((+ )*D)^(E-F) AB
7 ( *D)^(E-F) AB+
8 (* D)^(E-F) AB+
9 (* )^(E-F) AB+D
11 ^ (E-F) AB+D*
12 ^( E-F) AB+D*E
13 ^( -F) AB+D*E
14 ^(- F) AB+D*E
Page | 21
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
15 ^(- ) AB+D*EF
16 ^ End AB+D*EF-
Postfixexpression=AB+D*EF-^
3. REVERSAL A LIST: To reverse a list, the elements of list are pushed
onto the stack one by one. Once all elements are pushed on the stack
they are popped one by one. Since the element last pushed in comes
out first, hence reversal of string occurs.
Example: a list contains elements as {1, 2, 3, 4, 5, 6}. Every push operator
will push an element on top ofstack.
Once all elements are pushed one can pop all elements and save it
which results in to reversing of list as {6, 5, 4, 3, 2, 1}.
Page | 22
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
return f(x-1)*x; // line 2
void main(){
So at this point none of the functions have yet returned! The first to return will be f(1)
which will return 1. Then f(2) will return 2. Then f(3) will return 6. As i
Page | 23
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
Page | 24
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
c) Differentiate between linear linked list, circular linked list and doubly linked list.(
Min. 4 points each).
Ans: (4 points: 8
marks)
(**Note:
description
of each
stating
difference
shall also be
considered**
)
Page | 25
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
6. Attempt any two : 16 Marks
a) Write a program for insert and delete operation perform on queue. State any two 8M
application of queue.
Application of queue:
1) Simulation
2) CPU scheduling in multiprogramming and time sharing systems.
3) Queue is in round robin scheduling algorithm
4) Serving requests on a single shared resource, like a printer, CPU task scheduling etc.
5) In real life, Call Center phone systems will use Queues, to hold people calling them
in an order, until a service representative is free.
6) Handling of interrupts in real-time systems.
b) Draw tree for given expression and find inorder, preorder and postorder traversal. 8M
(a – 2b + 5c)2 (4d – 6e)5.
Page | 27
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
Ans: (Tree
creation:4
marks,
inorder:1
mark,
preorder:1
mark,postor
der:2 marks)
Figure – 1
i)Write Adjacency matrix representation.
ii) Depth first taversal sequence.
iii) Find all simple path from X to W.
iv) Find indegree (X) and outdegree (W).
Page | 28
MAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION
(Autonomous)
(ISO/IEC - 27001 - 2005 Certified)
MODEL ANSWER
SUMMER– 17 EXAMINATION
Subject Title: DATA STRUCTURE USING ‘C’ Subject Code: 17330
Ans: i)Write Adjacency matrix representation (2 marks)
W X Y Z
W 0 0 0 0
X 0 0 1 1
Y 0 1 0 1
Z 1 1 0 0
b)X-Y-Z-W
(1 marks)
iv) Find indegree (X) and outdegree (W).
indegree(X)=2
outdegree(W)=0
Page | 29