# Data Structure Questions and Answers – Parallel Array

«
»

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses 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

Explanation: 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)

Note: Join free Sanfoundry classes at Telegram or Youtube
```   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)

Take Data Structure I Practice Tests - Chapterwise!
Start the Test Now: Chapter 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
```   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]```
Explanation: 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

Explanation: 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

Explanation: 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

Explanation: 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

Explanation: 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

Explanation: 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)

Explanation: 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).

Sanfoundry Global Education & Learning Series – Data Structure.

To practice all areas of Data Structure, here is complete set of 1000+ Multiple Choice Questions and Answers.