DS Part-B&C Question Bank For IA1
DS Part-B&C Question Bank For IA1
1. Consider an array A [1: n] Given a position, write an algorithm to insert an element in the
Array. If the position is empty, the element is inserted easily. If the position is already occupied
the element should be inserted with the minimum number of shifts. (Note: The elements can
shift to the left or to the right to make the minimum number of moves).
2. Consider the SLL which contains the following elements 42, 78, 95, and 100. Insert 56 at the
beg, insert 125 at the end, insert 29 between 78 and 95, delete at the beginning, delete at the end,
and delete 95. Perform the above operations, represent the list accordingly, and explain SLL
routines for each category of insertion, deletion, search, and traverse.
3. Describe the various methods for inserting nodes into a doubly linked list, including insertion at the
beginning, end, and a specific position. Provide algorithms for each method, explaining how pointers are
managed to maintain the list's integrity. Illustrate each algorithm with examples demonstrating the
insertion process in a practical context.
4. Describe a step-by-step procedure to insert and delete nodes at both the beginning and end of a
circular linked list. Include a detailed example demonstrating these operations, highlighting how the
circular nature affects traversal and manipulation of pointers or references.
5. Describe a step-by-step procedure to insert and delete nodes at both the beginning and end of a
circular linked list. Include a detailed example demonstrating these operations, highlighting how the
circular nature affects traversal and manipulation of pointers or references.
Polynomial addition. Represent the following polynomial expression using an array and linked list.
7. Explain in detail how operations commonly associated with lists, such as insertion, deletion,
and traversal, are implemented using arrays as the underlying data structure.
Polynomial addition. Represent the following polynomial expression using an array and linked list.
P(X1) = 10X5+8X4+2X2+4X+6
P(X2) = 5x3+4x2+3x+2
UNIT -2
1. Perform the following operations in the given order on an empty stack of size 5. Display the
stack after each operation. Mention the top of the stack, push (20), push (72), push (68), pop (),
push (84), push (10), pop. Sketch the stack operations routines.
2. Demonstrate insertion and deletion operations performed on a circular queue. Outline the
routines in detail.
3. Develop an algorithm to perform the four operations in a double ended queue that is
implemented as an array.
4. Write an algorithm to convert an infix expression to a postfix expression. Trace the algorithm to
convert the following infix expression to a postfix expression.
i. A+(B*C-(D/E^F)*G)*H
ii.((A-(B+C)*D)$(E+F))
8. Write an algorithm to convert an infix expression to a postfix expression. Trace the algorithm
to convert the following infix expression to a postfix expression.
i. A+(B*C-(D/E^F)*G)*H
ii.((A-(B+C)*D)$(E+F))
11. Define AVL tree and starting with an empty AVL search tree, insert the following elements in
the given order:5,12,10,9,8,14,23,29,28,17. Explain each step with its algorithm. Delete the
following elements 14,9,28.
12. Compare the efficiency of insertion and deletion operations in threaded binary trees
versus standard binary trees. Under what circumstances would a threaded binary tree be
more efficient?
UNIT-3
1. i) Convert the given binary tree into threaded binary tree using single threaded binary tree method
and double threaded binary tree method.
ii)Do the following operations in binary search tree, insert(root,5), insert(root,1), insert(root,15),
insert(root,9), insert(root,7), insert(root,12), insert(root,30), insert(root,25), insert(root,40),
insert (root, 45), insert (root, 42), in order(root), delete (root, 1), delete(root,9), delete(root,30).
Perform tree traversal after the construction of the tree.
2. i) Construct an expression tree for the expression (a + b * c)+((d * e + 1) * g). Give the outputs when
you apply pre order, in order and post order traversals.
ii) Explain AVL tree ADT in detail.
3. Construct BST for the following elements, 7,5,1,8,3,6,0,9,4,2. Write an algorithm for preorder, in
order and post order traversal of a binary tree. Compute the same for the above tree.
4. i) Explain the construction of expression tree with example.
ii)Give the applications of trees