Chapter 1
These are the solutions to the exercises found in the section Exercises.
-
Let’s break down each of the cases:
-
Reading from an array always takes just one step.
-
Searching for a nonexistent element within an array of size 100 will take 100 steps, as the computer needs to inspect each element of the array before determining the element cannot be found.
-
The insertion will take 101 steps: 100 shifts of each element to the right, and one step to insert the new element at the front of the array.
-
Insertion at the end of an array always takes one step.
-
The deletion will take 100 steps: first the computer deletes the first element and then shifts the remaining 99 elements to the left, one at a time.
-
Deletion at the end of an array always takes ...
-
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access