My Report

Data Structure I Mock Test 2


Correct Answer: 2 points | Wrong: -1 point
Grades: A* (100% score) | A (80%-99%) | B (60%-80%) | C (40%-60%) | D (0%-40%)
advertisement
 10%

Question 1 of 10

1. In linked list implementation of a queue, where does a new element be inserted?

Question 1 of 10

Question 2 of 10

2. Express -15 as a 6-bit signed binary number.

Question 2 of 10

Question 3 of 10

3. In the given C snippet, find the statement number that has error.

//C code to push an element into a stack
1. void push( struct stack *s, int x) 
2. {
3.     if(s->top==MAX-1)
4.     {
5.         printf(“stack overflow”);
6.     }
7.     else
8.     {
9.         s->items[++s->top]=x;
10.        s++;
11.    }   
12. }

Question 3 of 10

Question 4 of 10

4. Write a piece of code which returns true if the string contains balanced parenthesis, false otherwise.

Question 4 of 10

Question 5 of 10

5. Find the output of the following prefix expression.

*+2-2 1/-4 2+-5 3 1

Question 5 of 10

Question 6 of 10

6. What would be the Prefix notation for the given equation?

A^B^C^D

Question 6 of 10

Question 7 of 10

7. In Postfix expressions, the operators come after the operands.

Question 7 of 10

Question 8 of 10

8. What is the time complexity of the following code?

public boolean isBalanced(String exp)
{
	int len = exp.length();
	Stack<Integer> stk = new Stack<Integer>();
	for(int i = 0; i < len; i++)
        {
		char ch = exp.charAt(i);
                if (ch == '(')
                stk.push(i);
                else if (ch == ')')
                {
			if(stk.peek() == null)
                        {
				return false;
			}
			stk.pop();
		}
	}
	return true;
}

Question 8 of 10

Question 9 of 10

9. Identify the infix expression from the list of options given below.

Question 9 of 10

Question 10 of 10

10. Making the push operation costly, select the code snippet which implements the pop operation.

Question 10 of 10


 

Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.