DEPARTMENT OF APPLIED MATHEMATICS
Data Structure (MC201)
ASSIGNMENT-I
AY 2025-26
Q1. Implement a recursive method that prints all permutations of a given string. The program takes two
strings as input. The output is all rearrangements of the letters in first, followed by second
/* Example output:
Permutations ("CAT", "MAN") will print this:
CATMAN
CTAMAN
ACTMAN
ATCMAN
TACMAN
TCAMAN
*/
Q2. Implement a Queue using 2 stacks (write the pseudocode). What are the complexities of enqueue()
and dequeue() operations?
Q3. Transform each of the following expressions to polish and reverse polish notation:
(a) A+B-C
(b) (A+B)*(C-D)^E*F
(c) A+(((B-C)*(D-E)+F)/G)^(H-J)
Q4. Apply the evaluation algo to evaluate the following postfix expressions:
AB+C-BA+C^- (Assume A=1, B=2, C=3)
Q5. State and explain the applications of Stack data structure.
Q6. Perform (stepwise) postfix expression evaluation with single digit operands using a stack:
823^/23*+51*-
Q7. Draw the stack structure in each case when the following operations are performed on an empty stack.
(a) Add A, B, C, D, E, F
(b) Delete two letters
(c) Add G
(d) Add H
(e) Delete four letters
(f) Add I
Q8. If an array holding a queue is not considered circular, then each remove operation must shift down
every remaining element of the queue. An alternative method is to postpone shifting until rear equals the
last index of the array. When that situation occurs and an attempt is made to insert an element into the
queue, the entire queue is shifted down, so that the first element of the queue is in position 0 of the array.
What are the advantages of this method over performing a shift at each remove operation? What are the
disadvantages?
Q9. Consider the queue given below which has FRONT = 1 and REAR = 5.
A B C D E
Now perform the following operations on the queue: (a) Add F (b) Delete two letters (c) Add G (d) Add H
(e) Delete four letters (f) Add I
Q10. Explain the concept of a circular queue? How is it better than a linear queue?
Q11. A priority queue Q is used to implement a stack S that stores characters. PUSH(C) is implemented as
INSERT(Q, C, K) where K is an appropriate integer key chosen by the implementation. POP is
implemented as DELETEMIN(Q). For a sequence of operations, the keys (K) chosen are in
(A) non-increasing order
(B) non-decreasing order
(C) strictly increasing order
(D) strictly decreasing order
Choose the correct option and explain it.
Q12. Let P be a singly linked list. Let Q be the pointer to an intermediate node x in the list. What
is the worst-case time complexity of the best-known algorithm to delete the node x from the list?
Q13. Circularly linked list is used to represent a Queue. A single variable p is used to access the
Queue. To which node should p point such that both the operations enQueue and deQueue can be
performed in constant time? Choose the correct option.
(A) Rear node
(B) Front node
(C) Not possible with a single pointer
(D) Node next to front
Q14. Consider a singly linked list having n nodes. The data items d1, d2, …., dn are stored in the n
nodes. Let Y be a pointer to the jth node (1 ≤ j ≤ n) in which dj is stored. A new data item d stored
in a node with address Y is to be inserted. Give an algorithm to insert d into the list to obtain a list
having items d1, d2, ……, dj-1, d, dj, …..dn in that order without using the header.
Q15. Why linked lists are not suitable for binary search?
Q16. What does the following function do for a given Linked List with first node as head? void
fun(struct node* head)
{
if (head == NULL) return;
fun(head → next);
printf(“%d”, head → data);
}
Q17. What are the time complexities of finding the 8th element from beginning and 8th element from end in
a singly linked list? Let n be the number of nodes in the linked list, assume n>8.
***