Array Questions with Answers

11 practice questions on Array (Data Structures & Algorithms) with answers and step-by-step solutions. Try 10 samples below, then practise all 11 free in the AptiNest app.

Sample questions

Question 1Medium

Which of the following statements is not true?

  1. An array is a data structure containing a number of items of the same type
  2. An array is normally used to store two or more items of data
  3. The lower bound of an array can be declared as any unsigned value
  4. The elements of an array can be initialized when the array is declared

Answer: C. The lower bound of an array can be declared as any unsigned value

Explanation

As there is no any syntax to declare the lower bound of the array except the size of the array which can be declared.

Step-by-step solution

  1. The question asks for the statement that is NOT true.
  2. Options A, B and D are true: an array holds items of one type, is used for two or more items, and can be initialised when declared.
  3. Option C says the lower bound can be any unsigned value. In C-style arrays the lower bound is fixed at 0; only the size is declared.
  4. So the false statement is option C.

Why the other options are wrong

  • A. True: an array holds items of one data type, so this is not the false statement.
  • B. True: an array is normally used to store two or more items.
  • D. True: array elements can be given values when the array is declared.

Tip: In 'which is NOT true' questions, mark each option true or false, then pick the false one.

Question 2Medium

Each array declaration need not give, implicitly or explicitly, the information about

  1. the name of array
  2. the data type of array
  3. the first data from the set to be stored
  4. the index set of the array

Answer: C. the first data from the set to be stored

Explanation

Each array declaration need not give, implicitly or explicitly, the information about the first data from the set to be stored.

Step-by-step solution

  1. An array declaration gives the name, the data type and the index set (size or bounds).
  2. It does not need to give the first data value to be stored in the array.
  3. Marked answer: the first data from the set to be stored (option C).

Why the other options are wrong

  • A. The array name is always part of a declaration.
  • B. The data type is always part of a declaration.
  • D. The index set (size or bounds) is part of a declaration.

Tip: A declaration gives name, type and index set; the stored values are not required.

Question 3Medium

The simplest type of data structure is ...

  1. Multidimensional array
  2. Linear array
  3. Two dimensional array
  4. Three dimensional array

Answer: B. Linear array

Explanation

A Linear Array is a list of finite number of n homogeneous data elements i.e.the elements of same data types. All arrays are linear data structures, as are all lists.
Arrays are linear because multiple elements are allocated in contiguous memory. If the array is a pointer array, only the pointer array need be contiguous; the data being pointed at can reside anywhere in memory, whether contiguous or not (you might use a separate pointer array to indirectly alter the order of elements in another array). Large and dynamic multi-dimensional arrays are typically allocated as a large array of pointers each of which points to a small array of data elements.

Step-by-step solution

  1. Linear array stores elements in a single row.
  2. All elements are accessed using one index.
  3. It is the most basic and simplest structure.
  4. Other arrays are built on top of linear arrays.
  5. The answer is Linear array.

Why the other options are wrong

  • A. Multidimensional arrays are more complex than linear arrays.
  • C. Two dimensional arrays require extra memory and logic.
  • D. Three dimensional arrays are even more complex.

Tip: Remember: Linear array is the simplest data structure.

Question 4Medium

The elements of an array are stored successively in memory cells because

  1. by this way computer can keep track only the address of the first element and the addresses of other elements can be calculated
  2. the architecture of computer memory does not allow arrays to store other than serially
  3. both of above
  4. none of above

Answer: A. by this way computer can keep track only the address of the first element and the addresses of other elements can be calculated

Explanation

The elements of an array are stored successively in memory cells because by this way computer can keep track only the address of the first element and the addresses of other elements can be calculated.

Step-by-step solution

  1. Array elements are stored in consecutive memory cells.
  2. So the computer only needs to keep the address of the first element.
  3. The address of any other element is the first address plus its index times the element size: option A.

Why the other options are wrong

  • B. Memory does not force serial storage; arrays are contiguous by design, not by hardware limit.
  • C. Option B is wrong, so 'both of above' is wrong.
  • D. Option A is correct, so 'none of above' is wrong.

Tip: Array address of element i = base address + i × element size.

Question 5Medium

Two dimensional arrays are also called?

  1. Matrix Array
  2. Table Array
  3. Both a and b
  4. None of the Above

Answer: C. Both a and b

Explanation

Two dimensional arrays are called as matrix array and table arrays because they contains rows and columns.

Step-by-step solution

  1. Two dimensional arrays have rows and columns.
  2. They are also known as matrix arrays.
  3. They are also known as table arrays.
  4. Matrix array and table array are both correct.
  5. So the answer is Both a and b.

Why the other options are wrong

  • A. Matrix Array is one name but not the only name.
  • B. Table Array is one name but not the only name.
  • D. Both names are correct so this is wrong.

Question 6Medium

Which of the following data structure is linear data structure?

  1. Trees
  2. Graphs
  3. Arrays
  4. None of above

Answer: C. Arrays

Explanation

A Linear Array is a list of finite number of n homogeneous data elements i.e. the elements of same data types.

Step-by-step solution

  1. Arrays store elements in a sequence, one after another.
  2. Each element has a unique index, making it linear.
  3. Trees and Graphs have non-linear relationships between nodes.
  4. Linear data structures have elements arranged in a straight line.
  5. The correct answer is Arrays.

Why the other options are wrong

  • A. Trees are hierarchical and non-linear.
  • B. Graphs have multiple connections and are non-linear.
  • D. Arrays are linear, so this option is incorrect.

Tip: Remember arrays are linear, while trees and graphs are non-linear.

Question 7Medium

Arrays are best data structures

  1. for relatively permanent collections of data
  2. for the size of the structure and the data in the structure are constantly changing
  3. for both of above situation
  4. for none of above situation

Answer: A. for relatively permanent collections of data

Explanation

An array is a data structure that contains a group of elements. Typically these elements are all of the same data type, such as an integer or string.
Arrays are commonly used in computer programs to organize data so that a related set of values can be easily sorted or searched.

Step-by-step solution

  1. An array's elements sit side by side in memory with indexed access.
  2. Inserting or deleting in an array shifts other elements, which is costly.
  3. So arrays suit collections that stay relatively permanent: option A.

Why the other options are wrong

  • B. Frequently changing size and contents suits lists or linked structures better than arrays.
  • C. Option C needs arrays to fit both cases, but they fit only the stable case.
  • D. Option A does describe arrays well, so none of the above is wrong.

Tip: Arrays suit fast indexed reads on stable data; for frequent inserts and deletes, choose another structure.

Question 8Medium

Arrays are best data structures......

  1. For relatively permanent collections of data.
  2. When the size of the structure and the data in it are constantly changing.
  3. For both of above situation
  4. For none of the above

Answer: A. For relatively permanent collections of data.

Explanation

arrays suit relatively permanent collections because their size is fixed

Step-by-step solution

  1. An array has a fixed size.
  2. Fixed size suits data whose size stays about the same.
  3. So arrays are best for relatively permanent collections.
  4. Option A is the correct answer.

Why the other options are wrong

  • B. Changing size often is where arrays are weak; linked structures suit that.
  • C. Arrays do not suit changing size, so both situations is wrong.
  • D. Arrays do suit permanent collections, so none of the above is wrong.

Tip: Arrays suit fixed size, fast indexing data; linked lists suit frequent insertion and deletion.

Question 9Medium

The memory address of the first element of an array is called

  1. floor address
  2. Foundation Address
  3. first address
  4. base address

Answer: D. base address

Explanation

The memory address of the first element of an array is called base address.

Step-by-step solution

  1. Memory addresses are used to locate elements in an array.
  2. The first element's address is the starting point for accessing others.
  3. This starting point is known as the base address.
  4. Base address is the correct term for this concept.
  5. The answer is base address.

Why the other options are wrong

  • A. Floor address is not a standard term in computer science.
  • B. Foundation Address is not a recognized term in array terminology.
  • C. First address is too vague and not the correct technical term.

Tip: Remember that 'base address' is the standard term used in array operations.

Question 10Medium

The memory address of fifth element of an array can be calculated by the formula

  1. LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array
  2. LOC(Array[5])=Base(Array[5])+(5-lower bound), where w is the number of words per memory cell for the array
  3. LOC(Array[5])=Base(Array[4])+(5-Upper bound), where w is the number of words per memory cell for the array
  4. None of above

Answer: A. LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array

Explanation

The memory address of fifth element of an array can be calculated by the formula is:
LOC(Array[5]=Base(Array)+w(5-lower bound), where w is the number of words per memory cell for the array

Step-by-step solution

  1. For a one-dimensional array, the address of element i is Base + w × (i − lower bound).
  2. For element 5, this is LOC(Array[5]) = Base(Array) + w(5 − lower bound).
  3. Option A matches this formula exactly.
  4. So the correct answer is A.

Why the other options are wrong

  • B. It uses Base(Array[5]), but the base is the address of the array, not of one element.
  • C. It uses Base(Array[4]) and an upper bound, which is not the address formula.
  • D. Option A is the correct formula, so 'None of above' is wrong.

Tip: LOC = Base + w × (index − lower bound) for a one-dimensional array.

Practise all 11 questions free

The full question bank with timed practice, progress tracking and Vidya, your AI tutor. Free, no ads.

Open this topic in the app →

Related topics

See all Data Structures & Algorithms topics · All topics