WorksheetsQuiz81-DS
Total questions: 45
Worksheet time: 26mins
The following postfix expression with single digit operands is evaluated using a stack:
8 2 3 ^ / 2 3 * + 5 1 * -
The top two elements of the stack after the first * is evaluated are:
6, 1
5, 7
3, 2
1
Consider Stack is implemented using the array.
#define MAX 10
struct STACK
{
int arr[MAX];
int top = ___________;
}
What will be the initial value with which top is initialized?
0
-1
Garbage
None
User perform following operations on stack of size 5 then -
push(1); pop(); push(2); push(3); pop(); push(4); pop(); pop(); push(5);
at the end of last operation, total number of elements present in the stack are –
3
4
2
1
User perform following operations on stack of size 5 then -
push(1); pop(); push(2); push(3); pop(); push(2); pop();
pop(); push(4); pop(); pop(); push(5);
Which of the following is correct statement for stack ?
Stack Operations will be performed Smoothly
Underflow Occurs
Overflow Occurs
None of these
The post fix form of the expression
(A+B)*(C*D-E)*F/G is
AB+CD * E-FG/**
AB+CD *E-F **G/
AB+CD *E- *F*G/
AB+CDE* -*F*G/
In linked representation of stack the null pointer of the last node in the list signals ......
Beginning of the stack
Bottom of the stack
Middle of the stack
In between some value
The five items: A, B, C, D, and E are pushed in a stack, one after the other starting from A. The stack is popped four times and each element is inserted in a queue. Then two elements are deleted from the queue and pushed back on the stack. Now one item is popped from the stack.
The popped item is
E
B
C
D
Using Pop (S1,Item) ,Push(S1, Item), Getlist(Item), Pop(S2,Item), and the variables S1,S2(stacks with Top1 and Top2) and Item and given the input file: A,B,C,D,E,F Which stack are possible?
All possible stacks with A,B,C,D,E and F
No possible stacks with A,B,C,D,E and F
Exact and only those stacks which can be produced with S1 alone
Twice as many stacks as can be produced with S1 alone
Process of Removing element from the stack is called as __________.
pop
push
delete
remove
What happens when you push a new node onto a stack?
The new node is placed at the front of the linked list
The new node is placed at the back of the linked list
The new node is placed at the middle of the linked list
No Changes happens
The result of evaluating the post fix expression 10, 5, 4, +, *, 3, 9, 3, /,/ + is?
91
90
900
93
In liked representation of stack ....... holds the elements of the stack.
INFO fields
TOP fields
LINK fields
NULL fields
How many stacks are needed to implement a queue. Consider the situation where no other data structure like arrays, linked list is available to you.
1
2
3
4
In linked list implementation of a queue, front and rear pointers are tracked. Which of these pointers will change during an insertion into a NONEMPTY queue?
Only front pointer
Only rear pointer
Both front and rear pointer
None of the front and rear pointer
Deletion operation is done using ......... in a queue.
Front
Rear
Top
List
If the elements “E”, “F”, “G” and “H” are placed in a queue and are deleted one at a time, in what order will they be removed?
EFGH
GHEF
HGFE
EFHG
In linked list implementation of queue, if only front pointer is maintained, which of the following operation take worst case linear time?
Insertion
Deletion
To empty a queue
Both INSERTION and DELETION
......... form of access is used to add and remove nodes from a queue.
LIFO, Last In First Out
FIFO, First In First Out
Both a and b
None of these
New nodes are added to the ......... of the queue.
Front
Last
Middle
Both A and B
Deletion operation is done using ......... in a queue.
Front
Rear
Top
List
……………. Is a pile in which items are added at one end and removed from the other.
Stack
Queue
List
None of the above
Which data structure allows deleting data elements at front and inserting at rear?
Stacks
Queues
Dequeue
Binary search tree
Identify the data structure which allows deletions at both ends of the list but insertion at only one end.
Input restricted dequeue
Output restricted qequeue
Priority queues
Stack
………… is not the operation that can be performed on queue.
Insertion
Deletion
Traversal
None of these
Which of the following is not the type of queue?
Ordinary queue
Single ended queue
Circular queue
Priority queue
In the array implementation of circular queue, which of the following operation take worst case linear time?
Insertion
Deletion
To empty a queue
None
A circular queue is implemented using an array of size 10. The array index starts with 0, front is 6, and rear is 9. The insertion of next element takes place at the array index.
0
7
9
10
Suppose a circular queue of capacity (n – 1) elements is implemented with an array of n elements. Assume that the insertion and deletion operation are carried out using REAR and FRONT as array index variables,
respectively. Initially, REAR = FRONT = 0. The conditions to detect queue full and queue empty are
Full: (REAR+1) mod (n-1) == FRONT, empty: REAR == FRONT ==-1
Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR
Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT
None of these
If the MAX_SIZE is the size of the array used in the implementation of circular queue.
How is rear manipulated while inserting an element in the queue?
rear=(rear%1)+MAX_SIZE
rear=rear%(MAX_SIZE+1)
rear=(rear+1)%MAX_SIZE
rear=rear+(1%MAX_SIZE)
If the MAX_SIZE is the size of the array used in the implementation of circular queue, array index
start with 0, front point to the first element in the queue, and rear point to the last element in the queue.
Which of the following condition specify that circular queue is FULL?
Front==rear= -1
Front==(rear+1)%MAX_SIZE
Rear==front+1
Rear==(front+1)%MAX_SIZE
If the MAX_SIZE is the size of the array used in the implementation of circular queue, array index start with 0,
front point to the first element in the queue, and rear point to the last element in the queue.
Which of the following condition specify that circular queue is EMPTY?
Front=rear=0
Front= rear=-1
Front=rear+1
Front=(rear+1)%MAX_SIZE
Let the following circular queue can accommodate maximum six elements with the following data
front = 2 rear = 4 queue = _______; L, M, N, ___, ___
What will happen after ADD O operation takes place?
front = 2 rear = 5 queue = ______; L, M, N, O, ___
front = 3 rear = 5 queue = L, M, N, O, ___
front = 3 rear = 4 queue = ______; L, M, N, O, ___
front = 2 rear = 4 queue = L, M, N, O, ___
In a circular queue the value of r will be ..
r=r+1
r=(r+1)% [MAXSIZE – 1]
r=(r+1)% MAXSIZE
r=(r-1)% MAXSIZE
A circular queue is implemented using an array of size 10. The array index starts with 0, front is 6, and rear is 9. The DELETION of next element takes place at the array index.
0
6
7
5
void main()
{
char str1[] = "abcd";
char str2[] = "abcd";
if(str1==str2)
printf("Equal");
else
printf("Unequal");
}
Equal
Unequal
Error
None of these.
If the two strings are identical, then strcmp() function returns
1
0
-1
True
Which of the following function is more appropriate for reading in a multi-word string?
scanf()
gets()
printf()
puts()
What will be the output of the program ?
#include<stdio.h>
#include<string.h>
void main()
{
char str1[20] = "Hello", str2[20] = " World";
printf("%s", strcpy(str2, strcat(str1, str2)));
}
HelloWorld
World
WorldHello
Hello
What will be the output of the program ?
#include<stdio.h>
void main()
{
printf(5+"Good Morning");
}
Good Morning
M
Good
Morning
What will be the output of the program ?
#include<stdio.h>
void main()
{
char str[] = "Exam\0Glau";
printf("%s", str);
}
Exam
Exam Glau
Exam\0Glau
Glau
Which of the following correctly accesses the seventh element stored in arr, an array with 100 elements?
arr[6]
arr[7]
arr{6}
arr{7}
What is the return value of the following statement if it is placed in C program? strcmp("ABC", "ABC");
33
-1
1
0
String concatenation means -
Combining two strings.
Extracting a substring out of a string.
Partitioning the string into two strings.
Merging two strings.
"My salary was increased by 15%" Select the statement, which will EXACTLY reproduce the line of text above.
printf("My salary was increased by 15/%!");
printf("My salary was increased by 15%!");
printf("My salary was increased by 15'%'!");
printf("My salary was increased by 15%%!");
short testarray[4][3] = { {1}, {2,3}, {4,5,6}};
printf("%d", sizeof(testarray));
Assuming a short is two bytes long, what will be printed by the above code?
6
7
12
24
