Download Roll No - IndiaStudyChannel.com

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Linked list wikipedia , lookup

Lattice model (finance) wikipedia , lookup

B-tree wikipedia , lookup

Quadtree wikipedia , lookup

Red–black tree wikipedia , lookup

Interval tree wikipedia , lookup

Binary search tree wikipedia , lookup

Transcript
Roll No. …………………..
Lingaya’s University, Faridabad
B.Tech. 2nd Year (Term – IV)
Examination – Oct, 2010
D a t a S t r u c t u r e a n d Al g o r i t h m s ( C S - 2 0 1 )
[Time: 3 Hours]
[Max. Marks: 100]
Before answering the question, candidate should ensure that they
have been supplied the correct and complete question paper. No
complaint in this regard, will be entertained after examination.
Note: All questions carry equal marks. Attempt five questions.
Question No. 1 is compulsory. Select two questions from Section – B
and two from Section – C.
Section – A
Q-1. Part – A
Select the correct answer of the following multiple choice questions.
(1x10=10)
(i) The initial configuration of a queue is a, b, c, d, (‘a’ is in the front end).
To get the configuration d, c, b, a, one needs a minimum of
(a) 2 deletions and 3 additions
(b) 3 deletions and 2 additions
(c) 3 deletions and 3 additions
(d) 3 deletions and 4 additions
(ii) A binary tree in which every non-leaf node has non-empty left and right
subtrees is called a strictly binary tree. Such a tree with 10 leaves.
(a) cannot have more than 19 nodes
(b) has exactly 19 nodes
(c) has exactly 17 nodes
(d) cannot have more than 17 nodes
(iii) The average successful search time for sequential search on ‘n’ items
is
(a) n/2
(b) (n-1)/2
(c) (n+1)/2
(d) log (n) +1
1
(iv) The number of possible binary trees with 3 nodes is
(a) 12
(b) 13
(c) 5
(d) 15
(v) Which of the following sorting methods will be the best if number of
swapping done, is the only measure of efficiency?
(a) bubble sort (b) selection sort
(c) insertion sort
(d) quick sort
(vi) Which of the following sorting algorithm has the worst time complexity
of n log (n)?
(a) heap sort
(b) quick sort
(c) insertion sort
(d) selection sort
(vii) The information about an array that is used in a program will be stored
in
(a) symbol table
(c) system table
(b) activation record
(d) dope vector
(viii) Which of the following expression accesses the (ij)th entry of a (mxn)
matrix stored in column major form?
(a) n x (i-1) + j
(c) m x (n – j) + j
(b) m x ( j – 1) + i
(d) n x (m – i) + j
(ix) Stacks cannot be used to
(a) evaluate an arithmetic expression in postfix form
(b) implementing recursion
(c) convert a given arithmetic expression in infix form to its equivalent
postfix form
(d) allocate resources (like CPU) by the operating system.
(x) Which of the following abstract data type can be used to represent a
many to many relation?
(a) tree
(b) stack
(c) graph
(d) queue
Part- B
(i) Give the advantages and disadvantages of linked list over arrays.
(5)
(ii) Write an algorithm for deleting node from the beginning of the linked list.
(5)
2
Section – B
Q-2. (a) Define data structures. Name and explain them briefly. Also
discuss various operations of data structure.
(10)
(b) Differentiate between static and dynamic memory allocation. Define
malloc ( ) and calloc ( ) function.
(10)
Q-3. (a) What is the complexity of an algorithm? Discuss asymptotic
notations to represent the complexity.
(10)
(b) What is recursion? Give suitable example to represent recursion? (10)
Q-4. (a) Write an algorithm to perform push and pop operation on stack.
Clearly mention the overflow and underflow conditions?
(10)
(b) Why queue overflow condition is not checked when the queue is
implemented using linked-list?
(5)
(c) Give the algorithm for evaluation of postfix expression and covert the
following infix to postfix expression using a stack.
A*B-(C+D-E) +FG-(H+I-(J-K)/L-M)-N
(5)
Section – C
Q-5. (a) Write a algorithm to implement the circular queue. The program
(algorithm) must contain different functions for enqueue, dequeue and
display operations.
(10)
(b) Write the algorithm to insert a node in a circular linked list.
(i) at beginning
(ii) At the end
(10)
Q-6. (a) For a binary tree T, the in-order and pre-order traversal sequences
are as follows.
Pre order -  CKEAHBQJI
In order  KECHQJIBA
Draw the unique binary tree using the above sequences.
(10)
(b) Define height balanced tree. Draw the AVL tree for the given sequence.
3, 5, 11, 8, 4, 1, 12, 7, 2, 6, 10
(10)
3
Q-7. (a) Define directed and undirected graphs. How the graphs are
represented in memory? Write an algorithm to check whether the cycle is
there in the graph, if adjacency matrix is given.
(10)
(b) Write the algorithm for BFS and DFS. Also specify the data structure
used for these implementation.
(10)
Q-8. (a) Write an algorithm for the implementation of selection sort and sort
in increasing order the given sequence using the selection sort.
70, 20, 90, 10, 30, 50, 100, 40, 60, 80
(10)
(b) Write the algorithm for quick sort. Discuss the worst case and average
case complexity for quick sort. Also sort the given sequence using quick
sort.
30, 10, 70, 20, 60, 50, 100, 40, 90, 80
(10)
4