Contents

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)

b

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


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

a

Explanation: The size of the dynamic array is decreased/deallocated if the actual size of the array is less than 30% of the backend physical size. This is used to avoid memory wastage.


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

d

The growth factor of ArrayList in Java is
a) 1                        
b) 1.5     
c) 2                        
d) 0

b

Explanation: The growth factor of dynamic arrays (Array List) in Java is 3/2. The new array capacity is calculated as new_array_size = (old_array_size*3)/2+1.


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)

a

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

b