Data Structure MCQ - Array
Q1.How can we describe an array in the best possible way?
- The Array shows a hierarchical structure.
- Arrays are immutable.
- Container that stores the elements of similar types
- 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.
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.
- Elements of mixed data types can be stored.
- Easier to access the elements in an array
- Index of the first element starts from 1.
- 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.
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.
- Binary Search tree
- Caching
- Spatial locality
- 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.
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.
- 9
- 36
- 35
- 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.
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.
#includeint main() { int arr[5]={10,20,30,40,50}; printf("%d", arr[5]); return 0; }
- Garbage value
- 10
- 50
- 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.
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.
- int arr[2]=(10, 20)
- int arr(2)={10, 20}
- int arr[2] = {10, 20}
- 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.
Explanations :The answer is c because the values assigned to the array must be enclosed within a curly bracket.
- Stack and Queue data structures can be implemented through an array.
- Index of the first element in an array can be negative
- Wastage of memory if the elements inserted in an array are lesser than the allocated size
- 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.
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.
- N-1
- logN - 1
- N + logN - 2
- 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.
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.
- floor address
- foundation address
- first address
- base address
Answer:- (D).
- 560
- 565
- 570
- 575
Answer:- (A).
Copyright © 2022 Shineskill Software Pvt. Ltd., All rights reserved.