Free Online Flashcard Deck

6 Arrays and Collections Free Online FlashCards

Study 6 Arrays and Collections with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is an array?

Back

An array is an ordered collection whose elements are stored under one variable name and accessed by index.

02
Front

What indexes are valid for an array of length nn?

Back

For an array of length nn, valid indexes range from 00 through n−1n-1.

03
Front

What does updating an array element change?

Back

Assigning a new value to one index changes that element but does not change the array's length.

04
Front

What is array traversal?

Back

Traversal visits each element, usually in order. A traversal of nn elements takes approximately O(n)O(n) time.

05
Front

What does linear search return when a target is absent?

Back

Linear search checks elements from left to right and returns the first matching index, or −1-1 when the target is absent.

06
Front

What prerequisite does binary search have?

Back

Binary search requires the array to be sorted according to the same ordering used by the search.

07
Front

How can an algorithm find every matching index?

Back

Continue through the entire array and append every matching index. For [4, 2, 4, 7, 4], the matching indexes for 4 are [0, 2, 4].

08
Front

What must an average algorithm decide for an empty array?

Back

An average divides the sum by the number of elements, so the empty-array case must be handled before division.

09
Front

How should an array maximum be initialized?

Back

Initialize the candidate maximum from the first element, then compare the remaining elements with it.

10
Front

How does an in-place array reversal work?

Back

An in-place reversal swaps elements from both ends while moving inward. It runs in O(n)O(n) time and uses O(1)O(1) extra space.

11
Front

How can a set improve duplicate detection?

Back

A set records values already seen, allowing duplicate detection in approximately O(n)O(n) time at the cost of additional memory.

12
Front

Why sort an array before repeated searches?

Back

Sorting rearranges values into an order, such as ascending order, which can enable binary search and simplify reporting.