Array Basics: 16 MCQs with answers

All 16 multiple-choice questions from this kit, free and with no sign-up.

Warm-up · 10 questions

Q1. What is an array?

Beginner
A A dynamic list that can grow or shrink in size B A collection of elements of different data types C A collection of elements of the same data type stored in contiguous memory locations D A key-value pair data structure
Show answer & explanation

A collection of elements of the same data type stored in contiguous memory locations

An array is a fixed-size collection of elements of the same data type stored in contiguous memory locations.

Q2. How is an element accessed in an array?

Beginner
A By its index B By its key C By its value D By its memory address
Show answer & explanation

By its index

Array elements are accessed using their index, which represents their position in the array.

Q3. Which of the following is a disadvantage of arrays?

Beginner
A They allow random access B They use contiguous memory C They have a fixed size D They store elements of the same type
Show answer & explanation

They have a fixed size

Arrays have a fixed size determined at creation, which cannot be changed later.

Q4. What is a multidimensional array?

Beginner
A An array with only one dimension B An array that can store multiple data types C An array that can grow dynamically D An array of arrays
Show answer & explanation

An array of arrays

A multidimensional array is an array of arrays, such as a 2D array representing a matrix.

Q5. What is the space complexity of an array of size $n$?

Beginner
A $O(\log n)$ B $O(1)$ C $O(n^2)$ D $O(n)$
Show answer & explanation

$O(n)$

An array of size $n$ requires space proportional to $n$, so space complexity is $O(n)$.

Q6. What is the index of the first element in most programming languages?

Beginner
A 1 B Depends on the language C -1 D 0
Show answer & explanation

0

In many languages like C, C++, Java, and Python, array indices start at 0.

Q7. What happens if you try to access an array element with an index out of bounds?

Beginner
A The array automatically resizes B The element is set to null C The index is wrapped around D The program may crash or produce undefined behavior
Show answer & explanation

The program may crash or produce undefined behavior

Accessing out of bounds can lead to runtime errors or undefined behavior, as it accesses memory not allocated for the array.

Q8. Which of the following is true about arrays?

Beginner
A Arrays cannot be used to implement other data structures B Arrays are always dynamically sized C Arrays can store elements of different data types D Arrays provide constant-time access to elements by index
Show answer & explanation

Arrays provide constant-time access to elements by index

Arrays allow direct access to any element using its index in constant time.

Q9. Arrays can store elements of different data types.

Beginner
A True B False
Show answer & explanation

False

Arrays are homogeneous; they store elements of the same data type.

Q10. The size of an array can be changed after it is created.

Beginner
A True B False
Show answer & explanation

False

Static arrays have a fixed size determined at creation and cannot be resized.

Building up · 6 questions

Q11. What is the time complexity to access an element in an array by index?

Intermediate
A $O(n)$ B $O(1)$ C $O(\log n)$ D $O(n^2)$
Show answer & explanation

$O(1)$

Accessing an array element by index is a constant time operation because the memory address can be calculated directly.

Q12. What is the time complexity to insert an element at the beginning of an array of size $n$?

Intermediate
A $O(n)$ B $O(n^2)$ C $O(1)$ D $O(\log n)$
Show answer & explanation

$O(n)$

Inserting at the beginning requires shifting all existing elements one position to the right, which takes linear time.

Q13. What is the time complexity to delete an element from the end of an array of size $n$?

Intermediate
A $O(n)$ B $O(1)$ C $O(\log n)$ D $O(n^2)$
Show answer & explanation

$O(1)$

Deleting the last element does not require shifting any other elements, so it takes constant time.

Q14. What is the time complexity to search for an element in an unsorted array of size $n$?

Intermediate
A $O(1)$ B $O(n)$ C $O(n^2)$ D $O(\log n)$
Show answer & explanation

$O(n)$

In the worst case, you may need to check every element, resulting in linear time complexity.

Q15. What is the time complexity to search for an element in a sorted array using binary search?

Intermediate
A $O(n^2)$ B $O(\log n)$ C $O(n)$ D $O(1)$
Show answer & explanation

$O(\log n)$

Binary search repeatedly divides the search interval in half, resulting in logarithmic time complexity.

Q16. Which operation is NOT typically supported efficiently by a static array?

Intermediate
A Accessing an element by index B Updating an element by index C Inserting an element at an arbitrary position D Traversing all elements
Show answer & explanation

Inserting an element at an arbitrary position

Inserting at an arbitrary position requires shifting elements, which is inefficient ($O(n)$) for large arrays.

Make your own

Your notes can be a kit like these

Every kit here was made from real study material. Point Veda at a chapter, a PDF, a photo or a link and get notes, flashcards, practice MCQs, games and a scored test — free, in 42 languages.

  • Chapter notes
  • Flashcards
  • Practice MCQs
  • Scored tests
  • Exam prep

Get Veda free See what students get

Free to start · No ads · Works in 42 languages