# Data Structure Questions and Answers – Parallel Array

This set of Data Structure Multiple Choice Questions & Answers (MCQs) focuses on “Parallel Array”.

1. 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 collection can be ordered numerically, alphabetically, or in some other way, as long as the elements are evenly spaced.

2. 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: Binary search is favoured since the list is sorted and its time complexity is O. (logn).

3. 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 many uses since all commercial computing requires vast volumes of data, which is much more efficient if it is sorted. It makes the most of the reference and data cache’s proximity. Hash Tables use linked lists rather than arrays.

4. 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 scenario, an element must be added to the front of the array, requiring the majority of the elements to be transferred, resulting in an O time complexity (n).

5. 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: Arrays can be of various data types, but they must all have the same number of components. A record is represented by the elements at the corresponding index.

6. 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]```

```   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 arrays must be of the same length, containing the same number of elements.

7. 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: The addition and deletion of elements necessitates the movement of each element from its original place. This is going to be boring. Parallel arrays can be used for record collection, locality of reference, and Ideal Cache behaviour.

8. 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: The keys and values are accessed sequentially in the parallel array since one array holds the keys and the other holds the values. Locality of Reference is usually enhanced by sequential access. This is a benefit.

A group of parallel arrays (also known as a structure of arrays or SoA) is a type of implicit data structure in computing that represents a single array of records using multiple arrays. For and field of the record, it holds a separate, homogeneous data array with the same number of elements. The fields of a single record are then implicitly represented by items in each array that have the same index. Array indices replace references from one object to another. This is in contrast to the traditional method of storing all fields of each record in memory (also known as array of structures or AoS). For example, one might declare an array of 100 names, each of which is a string, and 100 ages.