DATA STRUCTURES AND ALGORITHMS
EXAM QUESTIONS WITH 100%
CORRECT ANSWERS L LATEST
VERSION 2025/2026.
_________ _______________ refer to how data is organized. - ANS Data structures
The _________________ ____ _____ doesn't just matter for organization's sake, but can
significantly impact how fast your code runs. - ANS organization of data
When you have a solid grasp on the various data structures and each one's performance
implications on the program that you're writing, you will have the keys to write fast and elegant
_______ that will ensure that your software will run quickly and smoothly. - ANS code
An ________ is simply a list of data elements. - ANS array
The _________ of an array is the number that identifies where a piece of data lives inside the
array. - ANS index
In most programming languages, we begin counting the index at ______. - ANS 0
Most data structures are used in four basic ways, which we refer to as ___________________. -
ANS operations
1 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
,The four operations are: - ANS Read, Search, Insert, Delete
______________ refers to looking something up from a particular spot within the data
structure. With an array, this would mean looking up a value at a particular index. For example,
looking up which grocery item is located at index 2 would be ___________ from the array. -
ANS Reading
____________ refers to looking for a particular value within a data structure. With an array, this
would mean looking to see if a particular value exists within the array, and if so, which index it's
at. For example, looking to see if "dates" is in our grocery list, and which index it's located at
would be searching the array. - ANS Searching
________________ refers to adding another value to our data structure. With an array, this
would mean adding a new value to an additional slot within the array. If we were to add "figs"
to our shopping list, we'd be inserting a new value into the array. - ANS Inserting
________________ refers to removing a value from our data structure. With an array, this
would mean removing one of the values from the array. For example, if we removed "bananas"
from our grocery list, that would be deleting from the array. - ANS Deletion
when we measure how "_______" an operation takes, we do not refer to how fast the operation
takes in terms of pure time, but instead in how many steps it takes. - ANS fast
We can measure the speed of an operation in terms of how many steps it takes. If Operation A
takes five steps, and Operation B takes 500 steps, we can assume that Operation A will always
be faster than Operation B on all pieces of hardware. Measuring the number of steps is
therefore the key to analyzing the speed of an operation. - ANS
Measuring the speed of an operation is also known as measuring its ________ ___________.
Throughout this book, we'll use the terms speed, time complexity, efficiency, and performance
interchangeably. They all refer to the number of steps that a given operation takes. -
ANS time complexity
2 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
,When a program declares an array, it ____________ a contiguous set of empty cells for use in
the program. So, if you were creating an array meant to hold five elements, your computer
would find any group of five empty cells in a row and designate it to serve as your array: -
ANS allocates
Now, every cell in a computer's memory has a specific address. It's sort of like a street address
(for example, 123 Main St.), except that it's represented with a simple number. Each cell's
memory address is one number greater than the previous cell. - ANS
With an __________,
1. A computer can jump to any memory address in one step. (Think of this as driving to 123
Main Street—you can drive there in one trip since you know exactly where it is.)
2. Recorded in each array is the memory address which it begins at. So the computer has this
starting address readily.
3. Every array begins at index 0. - ANS array
_____________ from an array is, therefore, a very efficient operation, since it takes just one
step. An operation with just one step is naturally the fastest type of operation. One of the
reasons that the array is such a powerful data structure is that we can look up the value at any
index with such speed. - ANS Reading
For _________________, To search for a value within an array, the computer starts at index 0,
checks the value, and if it doesn't find what it's looking for, moves on to the next index. It does
this until it finds the value it's seeking. - ANS searching
A basic search operation—in which the computer checks each cell one at a time—is known as
_______ ___________. - ANS linear search
Now, what is the maximum number of steps a computer would need to conduct a linear search
on an array? - ANS If the value we're seeking happens to be in the final cell in the array (like
"elderberries"), then the computer would end up searching through every cell of the array until
it finally finds the value it's looking for. Also, if the value we're looking for doesn't occur in the
3 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
, array at all, the computer would likewise have to search every cell so it can be sure that the
value doesn't exist within the array.
So it turns out that for an array of five cells, the maximum number of steps that linear search
would take is five. For an array of 500 cells, the maximum number of steps that linear search
would take is 500. - ANS Another way of saying this is that for N cells in an array, linear search
will take a maximum of N steps. In this context, N is just a variable that can be replaced by any
number.
it's clear that searching is less efficient than ___________, since searching can take many steps,
while reading always takes just one step no matter how large the array. - ANS reading
The efficiency of _____________ a new piece of data inside an array depends on where inside
the array you'd like to insert it. - ANS inserting
Let's say we wanted to add "figs" to the very end of our shopping list. Such an insertion takes
just one step. As we've seen earlier, the computer knows which memory address the array
begins at. Now, the computer also knows how many elements the array currently contains, so it
can calculate which memory address it needs to add the new element to, and can do so in one
step. - ANS Inserting a new piece of data at the beginning or the middle of an array, however,
is a different story. In these cases, we need to shift many pieces of data to make room for what
we're inserting, leading to additional steps.
The worst-case scenario for _________ ____ ___ _____—that is, the scenario in which insertion
takes the most steps—is where we insert data at the beginning of the array. This is because
when inserting into the beginning of the array, we have to move all the other values one cell to
the right. - ANS insertion into an array
insertion in a worst-case scenario can take up to N + 1 steps for an array containing N elements.
This is because the worst-case scenario is inserting a value into the beginning of the array in
which there are N shifts (every data element of the array) and one insertion. - ANS
___________—is like insertion, but in reverse. - ANS deletion
4 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
EXAM QUESTIONS WITH 100%
CORRECT ANSWERS L LATEST
VERSION 2025/2026.
_________ _______________ refer to how data is organized. - ANS Data structures
The _________________ ____ _____ doesn't just matter for organization's sake, but can
significantly impact how fast your code runs. - ANS organization of data
When you have a solid grasp on the various data structures and each one's performance
implications on the program that you're writing, you will have the keys to write fast and elegant
_______ that will ensure that your software will run quickly and smoothly. - ANS code
An ________ is simply a list of data elements. - ANS array
The _________ of an array is the number that identifies where a piece of data lives inside the
array. - ANS index
In most programming languages, we begin counting the index at ______. - ANS 0
Most data structures are used in four basic ways, which we refer to as ___________________. -
ANS operations
1 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
,The four operations are: - ANS Read, Search, Insert, Delete
______________ refers to looking something up from a particular spot within the data
structure. With an array, this would mean looking up a value at a particular index. For example,
looking up which grocery item is located at index 2 would be ___________ from the array. -
ANS Reading
____________ refers to looking for a particular value within a data structure. With an array, this
would mean looking to see if a particular value exists within the array, and if so, which index it's
at. For example, looking to see if "dates" is in our grocery list, and which index it's located at
would be searching the array. - ANS Searching
________________ refers to adding another value to our data structure. With an array, this
would mean adding a new value to an additional slot within the array. If we were to add "figs"
to our shopping list, we'd be inserting a new value into the array. - ANS Inserting
________________ refers to removing a value from our data structure. With an array, this
would mean removing one of the values from the array. For example, if we removed "bananas"
from our grocery list, that would be deleting from the array. - ANS Deletion
when we measure how "_______" an operation takes, we do not refer to how fast the operation
takes in terms of pure time, but instead in how many steps it takes. - ANS fast
We can measure the speed of an operation in terms of how many steps it takes. If Operation A
takes five steps, and Operation B takes 500 steps, we can assume that Operation A will always
be faster than Operation B on all pieces of hardware. Measuring the number of steps is
therefore the key to analyzing the speed of an operation. - ANS
Measuring the speed of an operation is also known as measuring its ________ ___________.
Throughout this book, we'll use the terms speed, time complexity, efficiency, and performance
interchangeably. They all refer to the number of steps that a given operation takes. -
ANS time complexity
2 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
,When a program declares an array, it ____________ a contiguous set of empty cells for use in
the program. So, if you were creating an array meant to hold five elements, your computer
would find any group of five empty cells in a row and designate it to serve as your array: -
ANS allocates
Now, every cell in a computer's memory has a specific address. It's sort of like a street address
(for example, 123 Main St.), except that it's represented with a simple number. Each cell's
memory address is one number greater than the previous cell. - ANS
With an __________,
1. A computer can jump to any memory address in one step. (Think of this as driving to 123
Main Street—you can drive there in one trip since you know exactly where it is.)
2. Recorded in each array is the memory address which it begins at. So the computer has this
starting address readily.
3. Every array begins at index 0. - ANS array
_____________ from an array is, therefore, a very efficient operation, since it takes just one
step. An operation with just one step is naturally the fastest type of operation. One of the
reasons that the array is such a powerful data structure is that we can look up the value at any
index with such speed. - ANS Reading
For _________________, To search for a value within an array, the computer starts at index 0,
checks the value, and if it doesn't find what it's looking for, moves on to the next index. It does
this until it finds the value it's seeking. - ANS searching
A basic search operation—in which the computer checks each cell one at a time—is known as
_______ ___________. - ANS linear search
Now, what is the maximum number of steps a computer would need to conduct a linear search
on an array? - ANS If the value we're seeking happens to be in the final cell in the array (like
"elderberries"), then the computer would end up searching through every cell of the array until
it finally finds the value it's looking for. Also, if the value we're looking for doesn't occur in the
3 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
, array at all, the computer would likewise have to search every cell so it can be sure that the
value doesn't exist within the array.
So it turns out that for an array of five cells, the maximum number of steps that linear search
would take is five. For an array of 500 cells, the maximum number of steps that linear search
would take is 500. - ANS Another way of saying this is that for N cells in an array, linear search
will take a maximum of N steps. In this context, N is just a variable that can be replaced by any
number.
it's clear that searching is less efficient than ___________, since searching can take many steps,
while reading always takes just one step no matter how large the array. - ANS reading
The efficiency of _____________ a new piece of data inside an array depends on where inside
the array you'd like to insert it. - ANS inserting
Let's say we wanted to add "figs" to the very end of our shopping list. Such an insertion takes
just one step. As we've seen earlier, the computer knows which memory address the array
begins at. Now, the computer also knows how many elements the array currently contains, so it
can calculate which memory address it needs to add the new element to, and can do so in one
step. - ANS Inserting a new piece of data at the beginning or the middle of an array, however,
is a different story. In these cases, we need to shift many pieces of data to make room for what
we're inserting, leading to additional steps.
The worst-case scenario for _________ ____ ___ _____—that is, the scenario in which insertion
takes the most steps—is where we insert data at the beginning of the array. This is because
when inserting into the beginning of the array, we have to move all the other values one cell to
the right. - ANS insertion into an array
insertion in a worst-case scenario can take up to N + 1 steps for an array containing N elements.
This is because the worst-case scenario is inserting a value into the beginning of the array in
which there are N shifts (every data element of the array) and one insertion. - ANS
___________—is like insertion, but in reverse. - ANS deletion
4 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.