MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What are the advantages of arrays?
A
Objects of mixed data types can be stored
B
Elements in an array cannot be sorted
C
Index of first element of an array is 1
D
Easier to store elements of same data type
Explanation: 

Detailed explanation-1: -In arrays, the elements can be accessed randomly by using the index number. Arrays allocate memory in contiguous memory locations for all its elements. Hence there is no chance of extra memory being allocated in case of arrays. This avoids memory overflow or shortage of memory in arrays.

Detailed explanation-2: -Answer: 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.

Detailed explanation-3: -Advantages of Array There isn’t any chance of extra memory being allocated if there is an array. This avoids the issue of overflow or shortage of memory. Other data structures like linked lists, stacks, queues, trees, and graphs can be accomplished using arrays.

Detailed explanation-4: -Arrays are extremely powerful data structures that store elements of the same type. The type of elements and the size of the array are fixed and defined when you create it. Memory is allocated immediately after the array is created and it’s empty until you assign the values.

There is 1 question to complete.