1.
Which of the following can be called a parallel array implementation?
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]
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]
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]
Answer: Option 'A'
All the arrays must have equal length, that is, contain same number of elements.
2.
To search for an element in a sorted array, which searching technique can be used?
Answer: Option 'C'
Binary Search
3.
What are some of the applications of sorted arrays?
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.
4.
What are the advantages of parallel arrays over the traditional arrays?
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.
5.
What are parallel arrays?
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.
6.
What are some of the disadvantages of parallel arrays?
Answer: Option 'D'
They share the drawbacks of arrays.
7.
What is a sorted array?
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.