Header Ads Widget

Data structure MCQs part-1

 Data structure MCQs:-

  1. What is an array? a) A collection of items stored at non-continuous memory locations b) A collection of items stored at continuous memory locations c) A collection of items stored at random memory locations d) A collection of items stored in registers

Answer: b) A collection of items stored at continuous memory locations

  1. How can we declare an array in C? a) By specifying only its size b) By initializing its elements c) By both specifying its size and initializing its elements d) None of the above

Answer: c) By both specifying its size and initializing its elements

  1. What is the formula for calculating the length of an array? a) LB - UB b) UB - LB c) UB + LB d) LB * UB

Answer: b) UB - LB

  1. What is the formula for calculating the address of any element in an array given the address of its first element? a) Loc(arr[k]) = base(arr) * k b) Loc(arr[k]) = base(arr) - w * k c) Loc(arr[k]) = base(arr) + w * k d) Loc(arr[k]) = base(arr) / w * k

Answer: c) Loc(arr[k]) = base(arr) + w * k

  1. How are elements of a two-dimensional array stored in column major order? a) Elements are stored row by row b) Elements are stored column by column c) Elements are stored in random order d) Elements are stored diagonally

Answer: b) Elements are stored column by column

  1. What is the formula for calculating the address of an element in a two-dimensional array stored in column major order? a) Loc(arr[i][j]) = base(arr) + w (ni + j) b) Loc(arr[i][j]) = base(arr) + w (mj + i) c) Loc(arr[i][j]) = base(arr) - w (ni + j) d) Loc(arr[i][j]) = base(arr) / w (ni + j)

Answer: b) Loc(arr[i][j]) = base(arr) + w (m*j + i)

  1. What is the formula for calculating the address of an element in a two-dimensional array stored in row major order? a) Loc(arr[i][j]) = base(arr) + w (ni + j) b) Loc(arr[i][j]) = base(arr) + w (mj + i) c) Loc(arr[i][j]) = base(arr) - w (ni + j) d) Loc(arr[i][j]) = base(arr) / w (ni + j)

Answer: a) Loc(arr[i][j]) = base(arr) + w (n*i + j)

  1. What is a stack? a) A data structure that stores elements at non-continuous memory locations b) A data structure that stores elements at continuous memory locations c) A data structure that stores elements in registers d) A linear data structure that follows a particular order in which the operations are performed

Answer: d) A linear data structure that follows a particular order in which the operations are performed

  1. What is the order followed by a stack? a) Random order b) First In First Out (FIFO) c) Last In First Out (LIFO) d) None of the above

Answer: c) Last In First Out (LIFO)

  1. What does the Push operation in a stack do? a) Removes an item from the stack b) Adds an item to the stack c) Returns the topmost item from the stack
d) Return the first inserted item into the stack

Answer : c) Return the topmost item from the stack


  Pre  ðŸ‘ˆ                                👉  Next  


Post a Comment

0 Comments