Parallel Array | Data Structure MCQs

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: Option 'C'

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.) None of these

Answer: Option 'A'

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

3.

What are the advantages of parallel arrays 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 behavior
   D.) All of the above

Answer: Option 'D'

In a record, if a field contains only 1 bit, extra space is needed to pad the bits, instead you can use parallel arrays to save space. Sequential access improves locality of reference and cache behavior.

4.

What are some of the disadvantages 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.) All of these

Answer: Option 'D'

They share the drawbacks of arrays.

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 these

Answer: Option 'D'

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: Option 'C'

Binary Search

7.

What are some of the applications of sorted arrays?

   A.) Commercial computing
   B.) Priority Scheduling
   C.) Discrete Mathematics
   D.) All of the Above

Answer: Option 'D'

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.

Parallel Array | Data Structure MCQs Download Pdf