Data Structures Multiple Choice Questions and Answers on Dynamic Array

1. 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
Answer: a

Explanation: It is a varying-size list data structure that allows items to be added or removed, it may use a fixed sized array at the back end.
2. 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.
Answer: c

Explanation: Physical size, also called array capacity is the size of the underlying array, which is the maximum size without relocation of data.
3. The number of items used by the dynamic array contents is its __________

a) Physical size
b) Capacity
c) Logical size
d) Random size
Answer: c

Explanation: By definition.
4. How will you implement dynamic arrays in Java?

a) Set
b) Map
c) HashMap
d) List
Answer: d

Explanation: ArrayList is used to implement dynamic arrays in Java.
5. 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[];
Answer: a

Explanation: This is a non-generic way of creating an ArrayList.
6. In what type of dynamic array do you divide the array into two parts?

a) Hashed Array Tree
b) Geometric Array
c) Bounded-size dynamic array
d) None of the mentioned
Answer: c

Explanation: The first part stores the items of the dynamic array and the second part is reserved for new allocations.
7. What are the advantages of dynamic arrays?

a) Locality of reference
b) Data cache utilization
c) Random access
d) All of the mentioned
Answer: d

Explanation: Dynamic arrays share the advantage of arrays, added to it is the dynamic addition of elements to the array.
8. 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)
Answer: b

Explanation: All the other elements will have to be moved, hence O(n).

Related

Multiple Choice Questions 2542589441795644057

Post a Comment

emo-but-icon

item