0% found this document useful (0 votes)
46 views7 pages

DS Imp Questions

Uploaded by

Mr Venki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
46 views7 pages

DS Imp Questions

Uploaded by

Mr Venki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

Sipna College of Engineering and Technology, Amravati

Department of Computer Science & Engineering


Session 2024-25
Year/Sem/Section: 2nd / 3rd /A,B,C
Subject: Data Structures

Question Bank (Unit 1 to 6)

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

1. Give and explain the algorithm for binary search


2. Explain the concept of sparse matrices and also explain its representation in memory.
3. Differentiate between:-
a)A Triangular matrix and A Tridiagonal matrix
b)A record and A linear array
4. Using Bubble sort algorithm find the number of comparison C and number of interchanges I
which alphabetize the n=6 letters in JUNGLE
5. Write algorithm of insertion in linear array with example
6. Consider the arrays AAA(5:50), BBB(-5:10) and CCC(18).
a) Find no elements in each array
b) Suppose Base(AAA)=300 and w=4 words per memory cell for AAA. Find the
address of AAA[15], AAA[35]and AAA[55]
7. Consider string S= AMRAVATI using bubble sort algorithm arrange the character
in S in alphabetical order and show all passes.
8. Consider the string S= PEOPLE . Apply bubble sort to arrange the character in S
in alphabetic order . Show all passes and also find the number of comparisons and number of
Interchanges.
9. Assume that array A contains the following numbers A:- 25, 38, 42, 45,53,68, 99.
Apply binary search to DATA for searching a ITEM=25. show the steps in applying the binary
search to this array.
10. Consider 2 arrays A and B declared using A(-5:5,3:33) and B(3:10,1:15,10:20).
a) Find the length of each dimension and the no of elements in A and B.
b) Consider element B[5,10,15] in B. Find effective indices E1,E2,E3 and the addresses of
the element assuming Base(B)=400 and there are w=4 words per memory location in column
major order.
11. Give the comment on record and record structure.
12. Consider 2 arrays A and B declared using A(-5:5,3:33) and B(3:10,1:15,10:20).
a) Find the length of each dimension and the no of elements in A and B.
b) Consider element B[5,10,15] in B. Find effective indices E1,E2,E3 and the addresses of the
element assuming Base(B)=400 and there are w=4 words per memory location in row major
order.
Unit-3
1. Consider the following polynomial equation:
P(x, y, z) =2xy2 z3+3x2 yz2+4xy3z+5x2 y2+6y3z+7x3 z+8xy2z5+9
i) Rewrite the polynomial so that the terms are lexicographical order.
ii) Suppose terms are ordered in the parallel arrays COEF, XEXP, YEXP, ZEXP with
HEAD nodes first. Assign values to LINK so that the linked list contains the ordered
sequence of terms.

2. Explain the following terms : (i) Header linked list (ii) Two Way Linked list
3. Let p(x,y,z) denote the following polynomial :

P(x,y,z)=8x2y2z – 6yz8+ 3x3 yz+2xy7z-5x2 y3-4xy7z3.

a) Rewrite the expression in lexicographical order


b) Suppose terms are stored in the linear arrays COEF, XEXP, YEXP, ZEXP with
HEAD nodes first. Assign values to LINK so that the linked list contains the ordered
sequence of terms.

4. Let p(x) denote the following polynomial :

P(x)=4x9 + 2x7 -15x5+10x2-2

Draw a diagram to represent p(x) by a header list with array structure.

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.

5. Let J and K be the integers and suppose Q(J,K) is recursively defined by

Q(J,K) = 5 if J<K
Q(J-K, K+2) + J if J>=K

Find Q(2 ,7), Q(5, 3) and Q(15, 2).

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

i. Find the values of Q(2 ,3) and Q(14, 3).


ii. What does this function do? Find Q(5861, 7)
8. Suppose A is the following list of 12 numbers. 44, 33, 11, 55, 77, 90, 40, 60, 92, 22, 88, 66
Arrange the list in ascending order by using the Quick Sort algorithm. Show all steps.
9. What is Queue? Write an algorithm for insertion and deletion from array representation of the
queue.
10. Translate the following infix expression into its equivalent postfix expression using
algorithmic steps. Q: ((A+B)/D) ((E-F)*G)
11. Suppose STACK is allocated N=6 memory cells and initially STACK is empty i.e.TOP=0.
Find the output of the following module.
1) Set A=2 and B=5
2) Call PUSH (STACK, A)
Call PUSH (STACK, 4)
Call PUSH (STACK, A+B)
Call PUSH (STACK, B+5)
Call PUSH (STACK, 9)
3) Repeat while TOP != 0
Call POP(STACK, ITEM)
Write : ITEM
[End of loop]
4) Return.
Unit-5
1) A Binary tree T has some nodes. The inorder & preorder traversal of T yields the following
sequence of nodes. Draw Tree.
Inorder : Q B K C F A G P E D H R
Preorder : G B Q A C K F P D E R H

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

4) Consider the following data items and corresponding weights as follows:


Data A B C D E F G H
Item

Weight 22 5 11 19 2 11 25 5
Construct the Huffman Tree.

5) Consider the following data items and corresponding weights as follows:


Data A B C D E F G H
Item

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

9) Draw a binary tree for following expression : A*B-(C+D)*(P/Q)


10) Explain binary tree and its memory representation in detail.
Unit 6

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

(i) Find adjacency matrix A of Graph G


(ii) Find path matrix P of G
(iii) Is the graph strongly connected ?
9. Explain the linked representation for the graph and hence describe the traversal of the
graph.
10. Suppose array A contains 14 elements as follows : 66, 33, 40, 22, 55, 88, 60, ll, 80,
20.50,44,77,10 Apply merge sort algorithm to arrange this list in ascending order.
Show all passes.
11. Write an algorithm for breadth first search.
12. Explain selection sort with the help of algorithm.

You might also like