/* */ Click to Join Live Class with Shankar sir Call 9798158723

Data Structure MCQ - Array


Q1.How can we describe an array in the best possible way?
  1. The Array shows a hierarchical structure.
  2. Arrays are immutable.
  3. Container that stores the elements of similar types
  4. The Array is not a data structure

Answer:- (C).
Explanations :The answer is c because array stores the elements in a contiguous block of memory of similar types. Therefore, we can say that array is a container that stores the elements of similar types.
Q2.Which of the following is the advantage of the array data structure?
  1. Elements of mixed data types can be stored.
  2. Easier to access the elements in an array
  3. Index of the first element starts from 1.
  4. Elements of an array cannot be sorted

Answer:- (B).
Explanations :The answer is b because the elements in an array are stored in a contiguous block of memory, so it is easier to access the elements of an array through indexing.
Q3.Which of the following highly uses the concept of an array?
  1. Binary Search tree
  2. Caching
  3. Spatial locality
  4. Scheduling of Processes

Answer:- (C).
Explanations :The answer is c, i.e., Spatial locality. Here, spatial locality means that the instruction accessed recently, then the nearby memory location would be accessed in the next iteration. As we know that in an array, all the elements are stored in a contiguous block of memory, so spatial locality is accessed quickly.
Q4.Which one of the following is the size of int arr[9] assuming that int is of 4 bytes?
  1. 9
  2. 36
  3. 35
  4. None of the above

Answer:- (B).
Explanations :The answer is b because the size of int type data is 4 bytes. The array stores 9 elements, so the size of the array is 9*4=36 bytes.
Q5.What is the output of the below code?
#include   
int main()  
{  
   int arr[5]={10,20,30,40,50};  
   printf("%d", arr[5]);  
  
    return 0;  
}  
  1. Garbage value
  2. 10
  3. 50
  4. None of the above

Answer:- (A).
Explanations :The answer is a because the indexing in an array starts from 0, so it starts from arr[0] to arr[4]. If we try to access arr[5] then the garbage value will be printed.
Q6.How can we initialize an array in C language?
  1. int arr[2]=(10, 20)
  2. int arr(2)={10, 20}
  3. int arr[2] = {10, 20}
  4. int arr(2) = (10, 20)

Answer:- (C).
Explanations :The answer is c because the values assigned to the array must be enclosed within a curly bracket.
Q7.Which of the following is the disadvantage of the array?
  1. Stack and Queue data structures can be implemented through an array.
  2. Index of the first element in an array can be negative
  3. Wastage of memory if the elements inserted in an array are lesser than the allocated size
  4. Elements can be accessed sequentially.

Answer:- (C).
Explanations :The answer is c. For example, if we have an array of size 10 elements and we have inserted only 5 elements in an array then there is a wastage of 5 memory blocks which cannot be utilized by another variable.
Q8.What is the minimum number of comparisons to find the 2nd largest element provided you have found the largest element?
  1. N-1
  2. logN - 1
  3. N + logN - 2
  4. N

Answer:- (B).
Explanations :The minimum number of comparisons required to find the 2nd largest element is N + logN - 2. Of this, N-1 comparisons are required to find the largest element. So, only logN - 1 extra comparisons are needed to find the 2nd largest element. To learn more about this, go through this article.
Q9.The memory address of the first element of an array is called
  1. floor address
  2. foundation address
  3. first address
  4. base address

Answer:- (D).
Q10.Consider an array A[20, 10], assume 4 words per memory cell and the base address of array A is 100. What is the address of A[11, 5] ? Assume row major storage.
  1. 560
  2. 565
  3. 570
  4. 575

Answer:- (A).