250+ TOP MCQs on Parallel Array and Answers

Data Structure Multiple Choice Questions on “Parallel Array”.

1. What are parallel arrays?
a) Arrays of the same size
b) Arrays allocated one after the other
c) Arrays of the same number of elements
d) Arrays allocated dynamically
Answer: c
Clarification: Different arrays can be of different data types but should contain same number of elements. Elements at corresponding index belong to a record.

2. Which of the following can be called a parallel array implementation?
a)

   firstName  = ['Joe','Bob','Frank','Hans']
   lastName   = ['Smith','Seger','Sinatra','Schultze']
   heightInCM = [169,158,201,199]
 
   for i in xrange(len(firstName)):
       print "Name:",firstName[i], lastName[i]
       print "Height in CM:,",heightInCM[i]

b)

   firstName  = ['Joe','Bob','Frank','Hans']
   lastName   = ['Smith','Seger']
   heightInCM = [169,158]
 
   for i in xrange(len(firstName)):
       print "Name:",firstName[i], lastName[i]
       print "Height in CM:,",heightInCM[i]

c)

   firstName  = ['Joe','Bob']
   lastName   = ['Smith','Seger','Sinatra','Schultze']
   heightInCM = [169,158]
 
   for i in xrange(len(firstName)):
       print "Name:",firstName[i], lastName[i]
       print "Height in CM:,",heightInCM[i]

d)

   firstName  = ['Joe','Bob']
   lastName   = ['Smith','Seger' ,'Schultze']
   heightInCM = [169,158]
 
   for i in xrange(len(firstName)):
       print "Name:",firstName[i], lastName[i]
       print "Height in CM:,",heightInCM[i]

View Answer

Answer: a
Clarification: All the arrays must have equal length, that is, contain same number of elements.

 
 

3. Which of the following is a disadvantage of parallel array over the traditional arrays?
a) When a language does not support records, parallel arrays can be used
b) Increased locality of reference
c) Ideal cache behaviour
d) Insertion and Deletion becomes tedious
Answer: d
Clarification: Insertion and deletion of elements require to move every element from their initial positions. This will become tedious. For Record collection, locality of reference and Ideal Cache behaviour we can use parallel arrays.

4. Which of the following is an advantage of parallel arrays?
a) Poor locality of reference for non-sequential access
b) Very little direct language support
c) Expensive to shrink or grow
d) Increased Locality of Reference
Answer: d
Clarification: Elements in the parallel array are accessed sequentially as one arrays holds the keys whereas other holds the values. This sequential access generally improves Locality of Reference. It is an advantage.

5. What is a sorted array?
a) Arrays sorted in numerical order
b) Arrays sorted in alphabetical order
c) Elements of the array are placed at equally spaced addresses in the memory
d) All of the mentioned
Answer: d
Clarification: The array can be sorted in any way, numerical, alphabetical or any other way but the elements are placed at equally spaced addresses.

6. To search for an element in a sorted array, which searching technique can be used?
a) Linear Search
b) Jump Search
c) Binary Search
d) Fibonacci Search
Answer: c
Clarification: Since the array is sorted, binary search is preferred as its time complexity is O(logn).

7. Which of the following is not an application of sorted array?
a) Commercial computing
b) Priority Scheduling
c) Discrete Mathematics
d) Hash Tables
Answer: d
Clarification: Sorted arrays have widespread applications as all commercial computing involves large data which is very useful if it is sorted. It makes best use of locality of reference and data cache. Linked lists are used in Hash Tables not arrays.

8. What is the worst case time complexity of inserting an element into the sorted array?
a) O(nlogn)
b) O(logn)
c) O(n)
d) O(n2)
Answer: c
Clarification: In the worst case, an element must added to the front of the array, which means that rest of the elements have to be shifted, hence the worst case time complexity becomes O(n).

Leave a Reply

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