MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What is the disadvantage of array data structure?
A
Elements of an array can be accessed in constant time.
B
The amount of memory to be allocated should be known beforehand.
C
Elements are stored in contiguous memory blocks.
D
Multiple other data structures can be implemented using arrays.
Explanation: 

Detailed explanation-1: -Insertion and deletion are quite difficult in an array as the elements are stored in consecutive memory locations and the shifting operation is costly. Allocating more memory than the requirement leads to wastage of memory space and less allocation of memory also leads to a problem.

Detailed explanation-2: -An array has a fixed size which means you cannot add/delete elements after creation. You also cannot resize them dynamically. Unlike lists in Python, cannot store values of different data types in a single array.

Detailed explanation-3: -What are the disadvantages of arrays? Explanation: Arrays are of fixed size. If we insert elements less than the allocated size, unoccupied positions can’t be used again. Wastage will occur in memory.

Detailed explanation-4: -Advantages of Arrays In an array, accessing an element is very easy by using the index number. The search process can be applied to an array easily. 2D Array is used to represent matrices. For any reason a user wishes to store multiple values of similar type then the Array can be used and utilized efficiently.

Detailed explanation-5: -Arrays store multiple data of similar types with the same name. It allows random access to elements. As the array is of fixed size and stored in contiguous memory locations there is no memory shortage or overflow. It is helpful to store any type of data with a fixed size.

There is 1 question to complete.