# The Data Structure Trivia Exam: Quiz!

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
| By Raj_daoo
R
Raj_daoo
Community Contributor
Quizzes Created: 1 | Total Attempts: 8,696
Questions: 20 | Attempts: 8,702  Settings  Do you have any idea what the data structure is? Data structure is a method that applies the appropriate structure and syntax to store and organize information. This quiz asks you what an array is, how to delete an item from an array which loop is correct, how to identify the underflow condition for a stack, and how to identify the correct set of statements. This great quiz will assist you with learning about data structure.

• 1.

### An Array is what kind of data structure.

• A.

Linear

• B.

Non- Linear

• C.

Complex

• D.

All the above

• E.

None

A. Linear
Explanation
An array is a linear data structure because it stores elements in a contiguous memory location. Each element in the array can be accessed using its index value, which represents its position in the array. The elements are stored in a sequential manner, allowing for efficient traversal and access. Therefore, the correct answer is "Linear."

Rate this question:

• 2.

### While inserting an item in an array of integers which loop is right, where pos is the pos at which insertion is to be made(assume array starts from 1 and N is the max no. of items in the array.)

• A.

For(i=pos;i>=1;i--) { A[i] = A[i+1]; }

• B.

For(i=pos ; i

• C.

For(i=N; i>=pos;i--) { A[i] = A[i+1]; }

• D.

For(i=N; i>=pos;i--) { A[i+1] = A[i] }

• E.

For(i=N; i

D. For(i=N; i>=pos;i--) { A[i+1] = A[i] }
Explanation
The correct answer is "for(i=N; i>=pos;i--) { A[i+1] = A[i] }". This loop starts from the last element of the array and moves towards the position where the insertion is to be made. It shifts each element one position to the right, creating space for the new element to be inserted at the desired position.

Rate this question:

• 3.

### To delete an item from an array which loop is correct, where p is the position of deletion( assume array starts from 1 and N is the max no. of items in the array.)

• A.

For(i=N;i>=pos;i--) { a[i] = a[i+1]; }

• B.

For(i=pos;i

• C.

For(i=pos;i

• D.

For(i=pos-1;i

• E.

None

B. For(i=pos;i
Explanation
The correct loop to delete an item from an array at position p is "for(i=pos;i

Rate this question:

• 4.

### What is the contents of the array after the execution of the following program :-int a[] = {10,30, 20, 10, 30, 40};for(i=1;i<=6;i++) {   for(j=i+1 ; j<= 6; j++)   {      if(a[i] == a[j])      {         a[j] = 0;      }}

• A.

Same

• B.

10,10, 20, 20, 30, 40

• C.

10,0 20, 0, 30, 40

• D.

10,30, 20, 0, 0, 40

• E.

40, 30 ,10, 0, 0, 0

D. 10,30, 20, 0, 0, 40
Explanation
The program iterates through the array and checks for duplicate elements. If a duplicate element is found, it sets the value of that element to 0. In this case, the initial array is {10, 30, 20, 10, 30, 40}. After executing the program, the duplicate elements 10 and 30 are replaced with 0. Therefore, the resulting array is {10, 30, 20, 0, 0, 40}.

Rate this question:

• 5.

### A Stack follows the principle of

• A.

LIFO

• B.

FIFO

• C.

BOTH A and B

• D.

None

A. LIFO
Explanation
A stack follows the principle of LIFO, which stands for "Last In, First Out." This means that the last element added to the stack will be the first one to be removed. It is similar to a stack of plates, where you can only remove the topmost plate. In a stack data structure, items are added and removed from the same end, known as the top of the stack. This principle allows for efficient insertion and deletion operations, making it useful in various applications like function calls, expression evaluation, and backtracking algorithms.

Rate this question:

• 6.

### With every push in the stack the   top

• A.

Decrements by one

• B.

Increments by one

• C.

Stays there itself

• D.

Its always a 0

• E.

None

B. Increments by one
Explanation
In a stack, the "top" refers to the position of the most recently added element. When a new element is pushed onto the stack, it becomes the new top element, causing the top position to increment by one. Therefore, the correct answer is "increments by one".

Rate this question:

• 7.

### Identify the UnderFlow condition for a Stack

• A.

If( top < 1)

• B.

If(top > 1)

• C.

If(top > N)

• D.

If( top < N)

• E.

None

A. If( top < 1)
Explanation
The correct answer is "if( top < 1)". This condition checks if the top of the stack is less than 1, which indicates that the stack is empty or underflowing. In a stack, the top represents the index of the last element, so if it is less than 1, it means there are no elements in the stack.

Rate this question:

• 8.

### Identify the OverFlow condition for a Queue

• A.

If(REAR > N)

• B.

If(REAR < = FRONT)

• C.

If(REAR < 0)

• D.

If(FRONT > REAR)

• E.

NONE

A. If(REAR > N)
Explanation
The correct answer is "if(REAR > N)". This condition checks if the rear of the queue is greater than the maximum size of the queue (N). If this condition is true, it indicates that the queue has reached its maximum capacity and cannot accept any more elements. This is known as an overflow condition in a queue.

Rate this question:

• 9.

### To Delete an item from a Queue identify the correct set of statements :-

• A.

Q[REAR] = item; REAR ++;

• B.

Item = Q[FRONT]; FRONT++;

• C.

Item = Q[REAR]; FRONT ++;

• D.

Item = Q[FRONT]; REAR ++;

• E.

NONE

B. Item = Q[FRONT]; FRONT++;
Explanation
The correct set of statements to delete an item from a Queue is "item = Q[FRONT]; FRONT++;" This is because in a Queue, the element that has been in the queue for the longest time is always at the front. So, to delete an item, we need to first assign the value of the item at the front of the queue to the variable "item" and then increment the value of the "FRONT" pointer to move it to the next element in the queue.

Rate this question:

• 10.

### To Insert an item from a stack identify the correct set of statements :-

• A.

top++; S[top] = Item;

• B.

Item = S[top]; top--;

• C.

S[item] = Top; item ++;

• D.

S[top] = item; top++;

• E.

None

A. top++; S[top] = Item;
Explanation
The correct set of statements to insert an item from a stack is "top++; S[top] = Item;". This set of statements first increments the top pointer to create space for the new item in the stack, and then assigns the item to the position pointed by the top pointer in the stack array.

Rate this question:

• 11.

### Which Data structure is best suited for the UNDO operation in Windows

• A.

Stack

• B.

Queues

• C.

Both Stack and Queues

• D.

Arrays

• E.

None

A. Stack
Explanation
The UNDO operation in Windows requires a data structure that follows the Last-In-First-Out (LIFO) principle, where the most recently performed action is undone first. A stack is the best-suited data structure for this purpose as it allows elements to be added and removed from only one end, the top. When an action needs to be undone, it can be easily popped off the stack, reversing the order of operations. Therefore, a stack is the most appropriate data structure for implementing the UNDO operation in Windows.

Rate this question:

• 12.

### Which data structure is best suited to print the documents in the printer

• A.

Stacks

• B.

Queues

• C.

Both Stacks and Queues

• D.

Arrays

• E.

None

B. Queues
Explanation
Queues are the best suited data structure for printing documents in a printer because they follow the First-In-First-Out (FIFO) principle. When multiple documents are sent to the printer, the documents are printed in the order they were received, just like how people stand in a queue and are served in the same order. This ensures that the documents are printed in a fair and orderly manner, without any document being skipped or delayed. Stacks, on the other hand, follow the Last-In-First-Out (LIFO) principle, which is not suitable for printing documents in the desired order. Arrays can be used, but queues provide a more efficient and logical approach for this specific task.

Rate this question:

• 13.

### Which one is the Application of Stack

• A.

Polished Notations

• B.

Storing return addresses of function calls

• C.

Reversing a String

• D.

Recursion

• E.

All of the Above

E. All of the Above
Explanation
The application of a stack includes all of the above options. Polished notations, such as postfix or prefix notations, can be evaluated using a stack. Storing return addresses of function calls is another common use of a stack in programming languages. Reversing a string can be achieved by pushing each character onto a stack and then popping them off in reverse order. Recursion, which involves calling a function within itself, can also be implemented using a stack to keep track of function calls. Therefore, all of the given options are valid applications of a stack.

Rate this question:

• 14.

### Write the postfix notation of A + B * C / D

• A.

ABCD+*/

• B.

AB*/CD+

• C.

ABC*D/+

• D.

ABCD*+/

• E.

A+B*C/D

C. ABC*D/+
Explanation
The given expression is A + B * C / D. In postfix notation, the operators are placed after their operands. To convert the expression to postfix, we start by placing A and B as operands. Then, we encounter the multiplication operator * and place it after B. Next, we encounter the division operator / and place it after C. Finally, we encounter the addition operator + and place it after the previous two operands and operator. Hence, the postfix notation of A + B * C / D is ABC*D/+.

Rate this question:

• 15.

### Write the prefix notation of A + B * C / D

• A.

/*+ABCD

• B.

+/*DCBA

• C.

+/*BCDA

• D.

ABCD+*/

• E.

/*+BDCA

C. +/*BCDA
Explanation
The given prefix notation is "+/*BCDA". This notation represents the expression A + (B * (C / D)). In prefix notation, the operator comes before the operands. Here, the "+" operator is applied to the result of the "*" operator, which in turn is applied to the result of the "/" operator. The operands A, B, C, and D represent variables or values.

Rate this question:

• 16.

### Find the value of the postfix expression :- ABCD ^*-  (IF A = 150, B=10, C=2 D=3)

• A.

70

• B.

80

• C.

150

• D.

0

• E.

1500

A. 70
Explanation
The given postfix expression "ABCD ^*- " can be evaluated as follows:
1. The symbol "^" represents the exponentiation operation. So, "C ^ D" means C raised to the power of D, which is equal to 2^3 = 8.
2. The symbol "*" represents the multiplication operation. So, "A * B" means A multiplied by B, which is equal to 150 * 10 = 1500.
3. The symbol "-" represents the subtraction operation. So, "A - B" means A minus B, which is equal to 1500 - 8 = 1492.
Therefore, the value of the postfix expression is 1492.

Rate this question:

• 17.

### Find the postfix expression of the following :- A OR B AND !C

• A.

ABC! AND OR

• B.

AB AND C! OR

• C.

ABC! AND OR

• D.

A AND B !C OR

• E.

NONE

C. ABC! AND OR
Explanation
The postfix expression of "A OR B AND !C" is "ABC! AND OR". In postfix notation, the operators are placed after their operands. Here, the expression "!C" is evaluated first because of the "!" operator. Then, "B AND !C" is evaluated because of the "AND" operator. Finally, "A OR (B AND !C)" is evaluated because of the "OR" operator.

Rate this question:

• 18.

### What is the advantage of a linear search?

• A.

Fast

• B.

Time consuming

• C.

Needs a sorted array

• D.

Does not needs a sorted array

• E.

ALL

D. Does not needs a sorted array
Explanation
The advantage of a linear search is that it does not require the array to be sorted. This means that the elements can be in any order and the linear search will still be able to find the desired element. This makes it a flexible and versatile search algorithm that can be used in various scenarios.

Rate this question:

• 19.

### What is the disadvantage of a binary search?

• A.

Fast

• B.

Time consuming

• C.

Needs a sorted array

• D.

Does not needs a sorted array

• E.

ALL

C. Needs a sorted array
Explanation
The disadvantage of a binary search is that it requires a sorted array. This means that before performing the search, the array must be sorted, which can be time-consuming and may require additional space. If the array is not already sorted, it would need to be sorted first, which adds an extra step and potentially increases the overall time complexity of the search algorithm.

Rate this question:

• 20.

### If the search item lies in the upper half in case of binary search which is the correct set of statements.

• A.

Top = mid + 1;

• B.

Top = mid - 1;

• C.

Bot = mid + 1;

• D.

Bot = mid - 1;

• E.

None

D. Bot = mid - 1;
Explanation
In binary search, the search item lies in the upper half when the value at the middle index is less than the search item. In this case, the correct set of statements is "bot = mid - 1;". This statement updates the lower bound of the search range to be one less than the middle index, effectively narrowing down the search range to the upper half.

Rate this question:

Related Topics Back to top