Data Structures: 21 MCQs with answers

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

Warm-up · 9 questions

Q1. A **data structure** is best described as:

Beginner
A A programming language's built-in syntax rules B A type of computer hardware component C A method of organizing and storing data for efficient use D A mathematical equation for sorting numbers
Show answer & explanation

A method of organizing and storing data for efficient use

A data structure is a method of organizing and storing data so it can be used efficiently for processing, retrieval, updating, and deletion.

Q2. Which of the following is a **primitive** data structure?

Beginner
A Array B char C Linked List D Stack
Show answer & explanation

char

Primitive data structures are atomic single-value types provided by the language: int, char, float, bool, pointer. Array, Stack, and Linked List are non-primitive collections.

Q3. An array stores primitive values but is classified as:

Beginner
A Primitive, because it holds ints B Non-primitive, because it uses pointers C Non-primitive, because it organizes multiple items D Primitive, because it is built into the language
Show answer & explanation

Non-primitive, because it organizes multiple items

The primitive/non-primitive line is about whether the type is atomic or a collection — not about what it contains. An array organizes multiple items, so it is non-primitive.

Q4. In a **linear** data structure, each element has:

Beginner
A A variable number of predecessors B No defined position in memory C Connections to many other elements D One predecessor and one successor
Show answer & explanation

One predecessor and one successor

Linear structures arrange elements sequentially: each element has a unique predecessor and successor, except the first and last.

Q5. Which of these is a **non-linear** data structure?

Beginner
A Array B Queue C Graph D Linked List
Show answer & explanation

Graph

Graph is non-linear — one element can connect to many others, forming networks. Queue, Array, and Linked List are linear.

Q6. A static data structure allocates memory at:

Beginner
A Compile time, with fixed size B Runtime, using malloc() C Runtime, using calloc() D Compile time, with flexible size
Show answer & explanation

Compile time, with fixed size

Static data structures allocate memory at compile time and have a fixed size, e.g., int arr[100]. Dynamic structures allocate at runtime.

Q7. Which structure follows **LIFO** order?

Beginner
A Stack B Queue C Tree D Graph
Show answer & explanation

Stack

Stack follows LIFO (Last In, First Out). Queue follows FIFO (First In, First Out).

Q8. The **undo button** in a text editor is best modeled by which data structure?

Beginner
A Stack B Tree C Graph D Queue
Show answer & explanation

Stack

Undo reverses the most recent action first — that is LIFO behavior, which is a Stack.

Q9. An array stores elements in contiguous memory, so its i-th element address is base + (i × element size), enabling O(1) random access.

Beginner
A True B False
Show answer & explanation

True

An array stores elements in contiguous memory, so its i-th element address is base + (i × element size), enabling O(1) random access.

Building up · 7 questions

Q10. An **Abstract Data Type (ADT)** specifies:

Intermediate
A The exact memory layout of the structure B The time complexity of every operation C What operations exist and how they behave D The programming language to use
Show answer & explanation

What operations exist and how they behave

An ADT is a logical description of what operations a data type supports and how they behave, without specifying how they are implemented.

Q11. A Stack ADT can be implemented using:

Intermediate
A Either an array or a linked list B Only an array C Only a linked list D Only a graph
Show answer & explanation

Either an array or a linked list

The Stack ADT defines the operations (push, pop, peek, isEmpty) but not the implementation. It can be built on either an array or a linked list.

Q12. For `int arr[4] = {10,20,30,40}` with base address 1000, where does `arr[2]` sit?

Intermediate
A 1008 B 1002 C 1012 D 1004
Show answer & explanation

1008

Address = base + (i × element size) = 1000 + (2 × 4) = 1008. This is why array access is $O(1)$.

Q13. You must insert a value at the **front** of a collection of 1000 items. Which structure does this in $O(1)$?

Intermediate
A Array, because it has direct access B Linked list, because it has direct access C Array, because elements are contiguous D Linked list, because only pointers change
Show answer & explanation

Linked list, because only pointers change

With an array, every existing element must shift — $O(n)$. With a linked list, you create one node and update two pointers — $O(1)$.

Q14. You must read the **500th** item from a collection of 1000. Which structure does this in $O(1)$?

Intermediate
A Array, because of direct address calculation B Linked list, because pointers are fast C Array, because it shifts elements D Linked list, because nodes are scattered
Show answer & explanation

Array, because of direct address calculation

Array access is $O(1)$ via the address formula. A linked list requires walking 500 nodes — $O(n)$.

Q15. Which real-world system is powered by a **Graph**?

Intermediate
A Railway ticket counter line B Google Maps navigation C Undo button in Photoshop D Folder system on a computer
Show answer & explanation

Google Maps navigation

Google Maps uses a Graph — locations as nodes, roads as edges. Undo uses Stack, railway line uses Queue, folders use Tree.

Q16. Which of the following is a **dynamic** data structure?

Intermediate
A Static stack B Linked list C A single char variable D int arr[100]
Show answer & explanation

Linked list

Dynamic data structures allocate memory at runtime using pointers and malloc()/calloc(). Linked lists, trees, and graphs are dynamic.

Topper level · 5 questions

Q17. Given a collection of 1000 items, you need to insert a value at the end. Which structure allows this operation in O(1) time complexity?

Advanced
A Array B Linked List C Queue D Stack
Show answer & explanation

Linked List

A linked list allows O(1) insertion at the end if you maintain a pointer to the last node, while an array requires O(n) time to resize or shift elements.

Q18. You have a binary search tree (BST) and want to find the 500th smallest element. What is the time complexity of this operation in the average case?

Advanced
A O(1) B O(log n) C O(n log n) D O(n)
Show answer & explanation

O(log n)

In a balanced BST, finding the k-th smallest element can be done in O(log n) time by traversing down the tree, maintaining a count of nodes visited.

Q19. If you need to frequently add and remove elements from both ends of a collection, which data structure would be most efficient?

Advanced
A Deque B Array C Stack D Linked List
Show answer & explanation

Deque

A Deque (double-ended queue) allows O(1) operations for adding and removing elements from both ends, unlike an array or linked list which may incur O(n) in some cases.

Q20. Which of the following statements about static and dynamic data structures is true?

Advanced
A Dynamic structures allocate memory at compile time. B Static structures are faster in access due to contiguous memory. C Dynamic structures use less memory overall. D Static structures can resize dynamically.
Show answer & explanation

Static structures are faster in access due to contiguous memory.

Static structures are faster in access because they use contiguous memory, while dynamic structures may have overhead due to pointer management.

Q21. In terms of memory allocation, which of the following data structures would require careful management to avoid memory leaks?

Advanced
A Static Stack B Queue C Linked List D Array
Show answer & explanation

Linked List

A linked list requires careful memory management because each node is allocated dynamically, and forgetting to free memory can lead to leaks, unlike static structures.

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