DS Imp Questions
DS Imp Questions
UNIT 1
1. Prove that the complexity of the first pattern matching algorithm is 0(n2).
2. What are the various operations associated with word processing ? How are they implemented
using basic string operations ?
3. Consider the pattern P = abc. Use slow pattern matching algorithm to find number of
comparisons to find the INDEX of P in each of the following texts T:-
(a) (bca) 8 (b) (ab)10 (c) (abc)5 (d) (ab)20 (e) (cbab)10
4. Give the comment on 'Algorithm and Complexity' along with example
5. Find the table and corresponding graph for the second pattern matching algorithm where the
pattern P=abaab.
6. Find the table and corresponding graph for second/fast pattern matching algorithm where
pattern P= a3bb
7. For each of the following patterns P and text T , find the number of Comparison to find
INDEX of P in T using Slow algorithm
1) P=aaa T=(aabb)3
2) P=abc T=(ab)5
3) P=aaba T=abaababb
8. Suppose T is the text “MARC STUDIES MATHEMATICS”. Use appropriate syntax to
change T so that it reads:
1) “MARC STUDIES ONLY MATHEMATICS”
2) “MARC STUDIES MATHEMATICS AND PHYSICS”
3) “MARC STUDIES APPLIED MATHEMATICS”
9. Explain the string operation
1)SUBSTRING
2)INDEX
3) //
4)LENGTH
10. Suppose T is the text “THE STUDENT IS ILL”. Use appropriate syntax to change T so that
it reads:
“THE STUDENT IS VERY ILL”
“THE STUDENT IS ILL TODAY”
“ THE STUDENT IS VERY ILL TODAY”
11. Explain the data structures operations in detail?
UNIT 2
2. Explain the following terms : (i) Header linked list (ii) Two Way Linked list
3. Let p(x,y,z) denote the following polynomial :
5. What do you mean by linked list ? give and explain the representation of linked list in
memory.
6. Write an algorithm for deleting a given node from a linked list with an example.
7. Give the meanings of each of the following terms and show how each of these
is handled
1. Garbage collection
2. Overflow
3.Underflow
8. Describe the linked list structure. Illustrate with an example the traversing of linked lists.
9. Discuss the advantages and disadvantages of linked lists over arrays.
10. Describe the algorithm for searching an element in linked list
Unit-4
1. Explain sequential memory representation of stack
2. Consider the infix expression (A + B) * C - D/F. Convert the expression into a postfix
expression using algorithmic steps.
3. What is the Priority Queue? Give a different representation of a Priority Queue.
4. Suppose S is the following list of 14 alphabetic characters: D A T A S T R U C T U R E S
Suppose the characters in S are to be sorted alphabetically. Use the quick sort algorithm
with stack to find the final position of the first character D.
Q(J,K) = 5 if J<K
Q(J-K, K+2) + J if J>=K
6. Consider the following infix expression. Convert it into its equivalent postfix
expression by using inspection and hand method.
I) Q: ((A+B) D) / (E-F)+G
II) Q: (A-B)*(D/E)
III) Q: A*(B+D)/E-F*(G+H/K)
7. Let a and b denotes the positive integers and suppose a function Q is recursively defined by
Q(a,b) = 0 if a<b
Q(a-b, b) + 1 if b<=a
2) A Binary tree T has some nodes. The inorder & preorder traversal of T yields the following
sequence of nodes. Draw Tree.
Inorder : E A C K F H D B G
Preorder :F A E K C D H G B
3) Suppose the following list of letters is inserted in order into an empty binary search tree :
J, R. D, G, T, E, M, H, P, A. F, Q.
i) Find the final tree T
ii) find the Inorder traversal of T
iii)find the postorder traversal of T
Weight 22 5 11 19 2 11 25 5
Construct the Huffman Tree.
Weight 2 7 24 32 37 42 42 120
Construct the Huffman Tree.
6) Traverse the given tree using Inorder , Preorder and Postorder traversal. Show step by step
traversal for all nodes.
2 3
4 5 6
7) Traverse the given tree using Inorder , Preorder and Postorder traversal. Show step by step
traversal for all nodes.
B C
D F G H
I J K
8) What is one way and two way inorder threaded a binary tree? Draw the same for a given
binary tree.
B C
D E
1. Explain the Warshall Algorithm. Justify with an example to find out the shortest path.
2. Suppose 9 cards are punched as follows : 348, 143, 361, 423, 538, 128,321, 543, 366
Given to a card sorter. Apply Radix sort to sort the numbers in three phases. What is
the complexity of the Radix sort algorithm?
3. Suppose 8 cards are punched as follows :82, 901, 100, 12, 150, 77, 55, 23. Given to a
card sorter. Apply Radix sort to sort the numbers in three phases. What is the
complexity of the Radix sort algorithm?
4. Assume that an array A contains the following elements : A : 77, 33, 44, 11, 88, 22,
66, 55. Apply selection sort to sort the elements of A in ascending order. Show all
passes and results.
5. Assume that an array A contains the following elements : A : 80, 90, 70, 60, 50, 35,
20. Apply selection sort to sort the elements of A in ascending order. Show all passes
and results.
6. Suppose an array A contains 8 elements as follows : 4, 3, 2, 10, 12, 1, 6, 5. Apply
Insertion sort algorithm to arrange the list in ascending order. Show all the passes and
results.
7. Write the algorithm for Depth First Search of Graph.
8. Consider the Graph G and where nodes are stored in an array DATA as follows:
DATA : X, Y, W, Z The graph is as follows :
X Y
Z W