Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Test  >  GATE Computer Science Engineering(CSE) 2027 Mock Test Series  >  Test: Arrays, Stack, Queues & Linked List- 1 - Computer Science Engineering (CSE) MCQ

GATE Computer Science Engineering(CSE) 2027 Test: Arrays, Stack, Queues


MCQ Practice Test & Solutions: Test: Arrays, Stack, Queues & Linked List- 1 (10 Questions)

You can prepare effectively for Computer Science Engineering (CSE) GATE Computer Science Engineering(CSE) 2027 Mock Test Series with this dedicated MCQ Practice Test (available with solutions) on the important topic of "Test: Arrays, Stack, Queues & Linked List- 1". These 10 questions have been designed by the experts with the latest curriculum of Computer Science Engineering (CSE) 2026, to help you master the concept.

Test Highlights:

  • - Format: Multiple Choice Questions (MCQ)
  • - Duration: 30 minutes
  • - Number of Questions: 10

Sign up on EduRev for free to attempt this test and track your preparation progress.

*Multiple options can be correct
Test: Arrays, Stack, Queues & Linked List- 1 - Question 1

What all is true about Stack data structure? (More than one option is correct)

Detailed Solution: Question 1

Last in First OUT: The last item that is inserted into a given stack is the first item to be deleted.
A stack can be implemented using minimum two queues.
Stack is a dynamic data structure. It does not have a fixed size in the memory, and hence, size of a stack increases using push() and pop() operations.

Test: Arrays, Stack, Queues & Linked List- 1 - Question 2

stack A has 4 entries as following sequence a,b,c,d and stack B is empty. An entry popped out of stack A can be printed or pushed to stack B. An entry popped out of stack B can only be printed.

Then the number of possible permutations that the entries can be printed will be ?

Detailed Solution: Question 2

permutations which start with D:
to print D first , all a,b,c must be pushed on to stack before popping D and the only arrangement possible = D C B A
permutations start with C:
you need to push a and b from stack A to stack B , now print C
content of stack B= b a (from top to bottom)
content of stack A = d
permutations possible = 3!/2! = 3 = they are c d b a, c b d a, c b a d --> 3 permutations here
permutations starting with b :
to print b first, a will be pushed onto stack B
content of stack B= a
content of stack A= c d
you can bring these out in (3! -1) as (d a c) is not possible--> 5 possible
permutations starting with a:
fix ab
a b _ _
in this a b c d or a b dc
fix ac
a c _ _
a c b d or a c d b
fix ad
a d _ _
a d c b
total 5
total = 1+3+5+5= 14

Test: Arrays, Stack, Queues & Linked List- 1 - Question 3

An item that is read as input can be either pushed to a stack and later popped and printed, or printed directly. Which of the following will be the output if the input is the sequence of items -1, 2, 3, 4, 5?

Detailed Solution: Question 3

The item can be pushed to stack and later popped and printed, or printed directly. 1, 2, 3, 4, 5 is the input then (a) is not possible because once pushed 1 is printed after 2. Similarly (c) and (d) are also not possible.

We can obtain the sequence by performing the operations in the manner given below.

The sequence obtained will be 3,4,5,2,1.

Hence, (b) is the output.

Test: Arrays, Stack, Queues & Linked List- 1 - Question 4

The concatenation of two lists is to be performed in O(1) time. Which of the following implementations of a list could be used?

Detailed Solution: Question 4

In circular doubly linked list, one does not need to traverse the whole list to find the end of the list.
The second list can be concatenated at any location. Only fixed number of pointers need to be changed. Hence can be done in O(1) time.

Test: Arrays, Stack, Queues & Linked List- 1 - Question 5

Which of the following is essential for converting an infix expression to the postfix form efficiently?

Detailed Solution: Question 5

Operator stack is used to convert infix expression to postfix form whereas operand stack is used to convert postfix to infix notation.

Test: Arrays, Stack, Queues & Linked List- 1 - Question 6

What can we say about the array representation of a circular queue when it contains only one element? 

Detailed Solution: Question 6

If a queue contains an element Front = Rear, it can neither be NULL nor be -1.
So, option (a) and (c) are wrong.
Since, it is a circular queue and bottleneck case arises in case of two elements where Front = Rear + 1 and Front = Rear - 1, both are possible.
So, what all we can say is Front = Rear ≠ NULL if only one element is there in circular queue.

Test: Arrays, Stack, Queues & Linked List- 1 - Question 7

In a compact single dimensional array representation for lower triangular matrices (i.e. all the elements above the diagonal are zero) of size n x n, non-zero elements (i.e. elements of the lower triangle) of each row are stored one after another, starting from the first row, the index of the (i, j)th element of the lower triangular matrix in this new representation is 

Detailed Solution: Question 7

Test: Arrays, Stack, Queues & Linked List- 1 - Question 8

Let A be a two-dimensional array declared as follows:
A : array [1 ... 10] [1... 15] of integer;
Assuming that each integer takes one memory location. The array is stored in row-major order and the first element of the array is stored at location 100, what is the address of the element A [i] [j] ?

Detailed Solution: Question 8

The array is stored in row-major order, that means the elements are stored in the memory row-wise. 
Suppose we have the 2D array
1 2 3
4 5 6
It will be stored in the memory as 1 2 3 4 5 6
If array is stored as column-major order then it will be stored as 1 4 2 5 3 6

Let A be a 2D array, A: array [b1 …. u1] [b2 …… u2], then 
To find the location of A[i][j] for a 2D array stored in Row-major order use the following formula:
 

Loc A[i][j] = L + [ (i - b1) (u2 - b2 +1) + (j  - b2) ] x M

L - base address of the array, i.e. address of the first element of the array

M - Memory Size, here each integer takes only 1 memory location therefore M = 1

Loc A[i][j] = 100 + [ (i - 1) (15 - 1 +1) + (j  - 1) ] x 1

                = 100 + (i - 1) 15 + j -1 = 15i + j + 84

Test: Arrays, Stack, Queues & Linked List- 1 - Question 9

An n x n array v is defined as follows: v[i, j] = i - j for all i, j, 1 < i < n, 1 < j < n.The sum of the elements of the array v is:

Detailed Solution: Question 9

Array is

Sum = 0 + 1 + 2 + ... + (-1) + (-2) + ... = 0.

Test: Arrays, Stack, Queues & Linked List- 1 - Question 10

Suppose you are given an array s[1...n] and a procedure reverse (s, i, j) which reverses the order of elements in between positions i and j (both inclusive). What does the following sequence do, where 1 < k < n:
reverse (s, 1, k):
reverse (s, k + 1, n):
reverse (s, 1, n);

Detailed Solution: Question 10

Effect of the given 3 reversals for any k is equivalent to left rotation of the array of size n by k.

∴ n = 7, k = 2
reverse (S, 1, 2) we get [2, 1, 3, 4, 5, 6, 7]
reverse (S, 3, 7) we get [2, 1, 7, 6, 5, 4, 3]
reverse (S, 1, 7) we get [3, 4, 5, 6, 7, 1,2]

56 docs|215 tests
Information about Test: Arrays, Stack, Queues & Linked List- 1 Page
In this test you can find the Exam questions for Test: Arrays, Stack, Queues & Linked List- 1 solved & explained in the simplest way possible. Besides giving Questions and answers for Test: Arrays, Stack, Queues & Linked List- 1, EduRev gives you an ample number of Online tests for practice
Download as PDF