Data Structure Questions and Answers – Dynamic Array

Uncategorized Computer Science & Engineering Data Structures & Algorithms

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Dynamic Array”.

1. Array is divided into two parts in ____________
A) Hashed Array Tree
B) Geometric Array
C) Bounded-size dynamic array
D) Sparse Array

Explanation: The first part stores the dynamic array’s objects, while the second part is set aside for new allocations.

2. Which of the following is a disadvantage of dynamic arrays?
A) Locality of reference
B) Data cache utilization
C) Random access
D) Memory leak

Explanation: Dynamic arrays have all of the benefits of arrays plus the ability to dynamically add elements to the array. If memory is not treated correctly during allocation and deallocation, it can be leaked. This is a downside.

3. What is the time complexity for inserting/deleting at the beginning of the array?
a) O(1)
b) O(n)
c) O(logn)
d) O(nlogn)

Explanation: As a result, all of the other elements would have to be relocated, resulting in O. (n).

4. Dynamic arrays overcome the limit of static arrays.
A) True
B) False

Explanation: The capability of static arrays is set. During memory allocation, the capacity must be specified. The capability of dynamic arrays does not need to be defined during memory allocation. Backend physical size of dynamic arrays is fixed, but capacity can be increased if desired. As a consequence, dynamic arrays outperform static arrays.

5. The size of the dynamic array is deallocated if the array size is less than _________% of the backend physical size.
A) 30
B) 40
C) 10
D) 20

Explanation: If the dynamic array’s real size is less than 30% of the backend physical size, the array’s size is reduced/deallocated. This is used to reduce memory loss.

6. Both Dynamic array and Dynamically memory allocated array are same.
A) True
B) False

Explanation: A larger value is used to fix the physical size of a Dynamic array. Arrays with dynamically allocated memory are those whose memory is allocated at runtime rather than at compile time. At the backend, dynamically memory allocated arrays have no physical size. As a result, dynamic arrays and dynamically memory allocated arrays are two distinct types of arrays.

7. In which of the following cases dynamic arrays are not preferred?
A) If the size of the array is unknown
B) If the size of the array changes after few iterations
C) If the memory reallocation takes more time i.e. expensive
D) If the array holds less number of elements

Explanation: When the size of the array is uncertain during memory allocation, the size changes after a few iterations, or memory reallocation is costly, dynamic arrays are favoured. The physical size of the collection is reduced as the number of components is reduced, and the reduction takes longer. In that case, regular arrays can be used instead of dynamic arrays.

8. The growth factor of ArrayList in Java is _______
A) 1
B) 1.5
C) 2
D) 0


Dynamic arrays (Array List) in Java have a 3/2 growth factor.
new array size = (old array size3)/2+1 new array size = (old array size3)/2+1 new array size = (old array size*3)/2+1 new array_

9. In special case, the time complexity of inserting/deleting elements at the end of dynamic array is __________
A) O (n)
B) O (n1/2)
C) O (log n)
D) O (1)

Explanation: In general, adding or removing elements at the end of a dynamic array takes O time (1). Elements are added to the dynamic array’s allocated space. If the physical size of the dynamic array is surpassed, the physical size is reallocated, and every element is copied from the original array. Adding a new element to the end of the array will take O(n) time.

10. Which of the following arrays are used in the implementation of list data type in python?
A) Bit array
B) Dynamic arrays
C) Sparse arrays
D) Parallel arrays

Explanation: In Python, dynamic arrays are used to implement the list data sort. In the Numpy module, sparse arrays are used to implement sparse matrices. The bitarray module implements all bit array operations.

11. What is a dynamic array?
A) A variable size data structure
B) An array which is created at runtime
C) The memory to the array is allocated at runtime
D) An array which is reallocated everytime whenever new elements have to be added

Explanation: It is a variable-size list data structure that allows items to be added or removed; at the back end, it can use a fixed-size array.

12. What is meant by physical size in a dynamic array?
A) The size allocated to elements
B) The size extended to add new elements
C) The size of the underlying array at the back-end
D) The size visible to users

Explanation: Physical size, also known as array power, is the maximum size of the underlying array without data relocation.

13. The number of items used by the dynamic array contents is its __________
A) Physical size
B) Capacity
C) Logical size
D) Random size

Explanation: The logical size refers to the number of items used by the dynamic array contents. Physical size refers to the maximum size of the underlying array without data redistribution.

14. How will you implement dynamic arrays in Java?
A) Set
B) Map
C) HashMap
D) List

Explanation: In Java, ArrayList is used to implement dynamic arrays.

15. Which of the following is the correct syntax to declare an ArrayList in Java?
A) ArrayList al = new ArrayList();
B) ArrayList al = new ArrayList[];
C) ArrayList al() = new ArrayList();
D) ArrayList al[] = new ArrayList[];

Explanation: This is a non-generic method of ArrayList construction.

A dynamic array, also known as a growable array, resizable array, dynamic table, mutable array, or array list, is a variable-size list data structure with random access that allows elements to be added or removed. Many modern mainstream programming languages come with standard libraries. Static arrays have a fixed capacity that must be defined at allocation, which is solved by dynamic arrays.

Leave a Reply

Your email address will not be published. Required fields are marked *