Font size
WorksheetsData Structures
Total questions: 40
Worksheet time: 29mins
Consider an empty stack. The order of performing the operations is: push(21), push(52), push(16), pop(), pop(), push(25), push(22), push(60), pop(), pop(), push(15), pop().
21, 25, 22, 15
21, 52, 16
21, 25
25, 21
What does the following code depict?
#define Size 5 //Maximum possible size of a stack
struct stack{
int data[SIZE];
int TOP;
}
void fun(){
if(ptr -> TOP == SIZE-1)
return;
}
Overflow
Underflow
Enqueue
Dequeue
What is the output of the below code?
#include <stdio.h>
int main()
{
int arr[5]={10,20,30,40,50};
printf("%d", arr[5]);
return 0;
}
10
Garbage value
50
None of the above
Which data structure is required to convert the infix to prefix notation?
Linked list
Binary tree
Stack
Queue
Which of the following is the prefix form of A+B*C?
A+(BC*)
+AB*C
ABC+*
+A*BC
What is the outcome of the prefix expression +, -, *, 3, 2, /, 8, 4, 1?
(a)
If the elements '1', '2', '3' and '4' are inserted in a queue, what would be order for the removal?
1234
4321
3241
None of the above
Which one of the following is the overflow condition if linear queue is implemented using an array with a size MAX_SIZE?
rear = front
rear = front+1
rear=MAX_SIZE -1
rear = MAX_SIZE
In the linked list implementation of queue, where will the new element be inserted?
At the middle position of the linked list
At the head position of the linked list
At the tail position of the linked list
None of the above
Hide Answer
What would be the output after performing the following operations in a Deque?
Insertfront(10);
Insertfront(20);
Insertrear(30);
Insertrear(40);
Deletefront();
Insertfront(50);
Deleterear();
Display();
10, 20, 30
50, 10, 30
40, 20, 30
None of the above
Consider the following code
struct node {
int data;
struct node *next;
} node ptr;
Which one of the following is the correct option to create a new node?
ptr= (node*)malloc(sizeof(node*))
ptr=(node)malloc(sizeof(node))
ptr=(node*)malloc(sizeof(node))
None of the above
Identify the data structures which allows deletions from both the ends of the list but insertion at only one end
Input restricted dequeue
Output restricted dequeue
Priority Queue
Stack
In Circular Queue the value of REAR will be?
rear = rear+1
rear=(rear+1)/MAX
rear=(rear+1)%MAX
rear=(rear-1)%MAX
Evaluate Postfix expression from given infix expression.
A + B (C + D) / F + D E
AB+CD*F/+D*E
ABCD+*F/+DE*+
ABCD+*/F+DE*
AB+CD*F/+DE*
Consider the following recursive implementation to find the nth fibonacci number:
Which of the following lines should be inserted to complete the above code?
fibo(n-1)
fibo(n-1) + fibo(n-2)
fibo(n*1) + fibo(n*2)
fibo(n/1) + fibo(n/2)
A 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 Insertion and Deletion can be performed in constant time?
rear node
front node
not possible with one pointer
node next to front
The following postfix expression with single digit operands is evaluated using a stack:
8 2 3 ^ / 2 3 * + 5 1 * -
Note that ^ is the exponentiation operator. The top two elements of the stack after the first * is evaluated are:
6,1
5,7
3,2
1,5
A single array A[1..MAXSIZE] is used to implement two stacks. The two stacks grow from opposite ends of the array. Variables top1 and top2 (topl< top 2) point to the location of the topmost element in each of the stacks. If the space is to be used efficiently, the condition for “stack full” is
(top1 = MAXSIZE/2) and (top2 = MAXSIZE/2+1)
top1 + top2 = MAXSIZE
(top1= MAXSIZE/2) or (top2 = MAXSIZE)
top1= top2 -1
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 == FRONT, empty: REAR == FRONT
Full: (REAR+1) mod n == FRONT, empty: (FRONT+1) mod n == REAR
Full: REAR == FRONT, empty: (REAR+1) mod n == FRONT
Full: (FRONT+1) mod n == REAR, empty: REAR == FRONT
program P reads in 500 integers in the range [0..100] exepresenting the scores of 500 students. It then prints the frequency of each score above 50. What would be the best way for P to store the frequencies?
An array of 100 numbers
An array of 50 numbers
An array of 500 numbers
A dynamically allocated array of 550 numbers
Let A be a square matrix of size n x n. Consider the following program. What is the expected output?
Transpose of matrix A
Adding 100 to the upper diagonal elements and subtracting 100 from diagonal elements of A
The matrix A itself
None of the above
Which of the following algorithm cannot be desiged without recursion −
Tower of Hanoi
Fibonacci Series
Tree Traversal
None of the above
Items in a priority queue are entered in a _____________ order
random
order of priority
as and when they come
LIFO
A graph in which all vertices have equal degree is known as ______
Full Binary Tree
Binary Search Tree
Threaded Tree
Complete Binary Tree
Minimum number of fields in each node of a doubly linked list is ______
1
2
3
4
A tree with n vertices has _____ no. of edges
n-1
n-2
2n
logn
The maximum no. of nodes at any level is
n
2^n
n+1
2n
For the Binary tree shown in Fig, the in-order traversal sequence is:
ABCDEFGHIJK
HIDEBFCGJKA
HDIBEAFCJGK
HDBEIAFJCKG
For the Binary Tree shown in fig, the pre-order traversal sequence is:
ABCDEFGHIJK
HIDEFGCABJK
HDEFIGCKJAB
ABDHIECFGJK
For the Binary Tree shown in fig, the post-order traversal sequence is:
ABCDEFGHIJK
HIDEBFJKGCA
HDEFIGCKJAB
ABDHIECFGJK
If this tree is used for sorting, the new number 8 should be placed as the
left child of the node labelled 30
right child of the node labelled 5
right child of the node labelled 30
left child of the node labelled 10
The set of all edges generated by DFS tree starting at node B is:
BADCGFE
AD
BACDEFG
Cannot generated
Graph traversal is different from a tree traversal, because:
trees are not connected
graphs may have loops
trees have root
None of these
Graphs are represented using ............
Adjacency tree
Adjacency graph
Adjacency linked list
Adjacency queue
What is the number of vertices of degree 2 in a path graph having n vertices,here n>2.
n-2
n
2
0
A file is a collection of
Information
Data
Records
Related Records
Which among one of is not a file operation?
Creation
Updation
Retrival
Security
Which are the following are true with respect to Indexed Sequential File?
Fast data retrieval
Records are of fixed length
Index table stores the address of the records in the file
All the above
B-tree structure has the following advantages?
B-trees improve the performance of a wide range of queries
B-trees provide fast and efficient algorithms to insert, update, and delete records that maintain
the key order.
B-trees perform well for small as well as large tables
All the above
(a) is used to compute the address of a record by using a hash function on the search key
value.
