Nothing Special   »   [go: up one dir, main page]

PART-A (Each 1 Mark) 20 Marks

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

Roll Number: NAME :

PSG College of Technology, Coimbatore


Department of Computer Applications

ME Communication Systems- III Semester -18LM38- Data Structures and Algorithms - Quiz 1

PART-A (Each 1 Mark) =20 Marks

1. The data structure required to check whether an expression contains balanced parenthesis is?
a) Stack b) Queue c) Array d) Tree

2. Determine the output?


void main()
{
int i=0, j=1, k=2, m;
m = i++ || j++ || k++;
printf("%d %d %d %d", m, i, j, k);
}
1123 B. 1 1 2 2 C. 0 1 2 2 D. 0 1 2 3

3. The postfix form of the expression (A+ B)*(C*D- E)*F / G is?


a) AB+ CD*E - FG /** b) AB + CD* E - F **G /
c) AB + CD* E - *F *G / d) AB + CDE * - * F *G /

4. What data structure would you mostly likely see in a non recursive implementation of a
recursive algorithm?
a) LinkList b) Stack c) Queue d) Tree

5. The process of accessing data stored in a serial access memory is similar to manipulating data on
a ------?
a) Heap b) Binary Tree c) Array d) Stack

6. The postfix form of A*B+C/D is?


a) *AB/CD+ b) AB*CD/+ c) A*BC+/D d) ABCD+/*

7. Which data structure is needed to convert infix notation to postfix notation?


a) Branch b) Tree c) Queue d) Stack

8. The prefix form of A-B/ (C * D ⋀ E) is?


a) -/*⋀ACBDE b) -ABCD*⋀DE c) -A/B*C⋀DE d) -A/BC*⋀DE

9. What is the result of the following operation


Top (Push (S, X))
a) X b) Null c) S d) None

10. The prefix form of an infix expression p + q - r * t is?


a) + pq - *rt b) - +pqr * t c) - +pq * rt d) - + * pqrt
Roll Number: NAME :
11. Which data structure is used for implementing recursion?
a) Queue b) Stack c) Array d) List

12. Convert the following infix expressions into its equivalent postfix expressions
(A + B ⋀D)/(E - F)+G
a) (A B D ⋀ + E F - / G +) b) (A B D +⋀ E F - / G +)
c) (A B D ⋀ + E F/- G +) d) None
13. Convert the following Infix expression to Postfix form using a stack
x + y * z + (p * q + r) * s, Follow usual precedence rule and assume that the expression is legal.
a) xyz*+pq*r+s*+ b) xyz*+pq*r+s+*
c) xyz+*pq*r+s*+ d) none

14. Which of the following statement(s) about stack data structure is/are NOT correct?
a) Stack data structure can be implemented using linked list
b) New node can only be added at the top of the stack
c) Stack is the FIFO data structure
d) The last node at the bottom of the stack has a NULL link

15. Consider the following operation performed on a stack of size 5.


Push(1);
Pop();
Push(2);
Push(3);
Pop();
Push(4);
Pop();
Pop();
Push(5);

After the completion of all operation, the no of element present on stack are
a) 1 b) 2 c) 3 d) 4

16. The type of expression in which operator succeeds its operands is?
a) Infix Expression b) pre fix Expression
c) postfix Expression d) None

17. Which of the following application generally use a stack?


a) Parenthesis balancing program b) Syntax analyzer in compiler
c) Keeping track of local variables at run time d) All of the above

18. Consider the following array implementation of stack:


#define MAX 10
Struct STACK
{
Int arr [MAX];
Int top = -1;
}
If the array index starts with 0, the maximum value of top which does not cause stack overflow is?
a) 8 b) 9 c) 10 d) 11
Roll Number: NAME :

19. If the elements “A”, “B”, “C” and “D” are placed in a stack and are deleted one at a time, in what
order will they be removed?
a) ABCD b) DCBA c) DCAB d) ABDC
20. Evaluate Postfix expression from given infix expression.
A + B * (C + D) / F + D * E

A. AB+CD*F/+D*E B. ABCD+*F/+DE*+
C. ABCD+*/F+DE* D. AB+CD*F/+DE*

PART-B (Each 3 Mark)=15 Marks

21. Given an array Arr of size N, swap the Kth element from beginning with Kth element from end.
Example 1:
Input:
N = 8, K = 3 Arr1[] = {1, 2, 3, 4, 5, 6, 7, 8}
Output: 1 2 6 4 5 3 7 8
Explanation: Kth element from beginning is 3 and from end is 6.

22. What is a Queue, how it is different from stack and how is it implemented?
23. Find power(x,y) without using pow function.
24. Check whether a given string is a palindrome or not.
25. Write an Algorithm for the insert and delete operations on Stack of size n.

----------------------------------------------------------------------------------------

You might also like