Free Online Flashcard Deck

07. Lists, Arrays, and Sequential Data Free Online FlashCards

Study 07. Lists, Arrays, and Sequential Data with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.

12 cards
01
Front

What is a list?

Back

A list is an ordered sequence of elements stored under one name; an array may represent the same idea in some programming languages.

02
Front

What index identifies the first element in zero-based indexing?

Back

The first element has index 0.

03
Front

What are the valid indexes for a list of length n?

Back

For a list of length n, the valid indexes usually range from 0 through n − 1.

04
Front

What happens to list length when an existing element is updated?

Back

Updating an existing element changes its value but does not necessarily change the list’s length.

05
Front

When is value-based traversal appropriate?

Back

Use value-based traversal when the program needs each value but does not need its position.

06
Front

What is an accumulator?

Back

An accumulator stores a result that is built during traversal, such as a total, count, average, or new collection.

07
Front

What does filtering do to a collection?

Back

Filtering keeps elements that satisfy a condition in a new list; the original list remains unchanged.

08
Front

What does collection transformation produce?

Back

Transformation creates a new value for each element. Doubling [2, 5, 7] produces [4, 10, 14].

09
Front

How should a maximum search be initialized?

Back

For a nonempty list, initialize the maximum with the first element, then compare the remaining elements.

10
Front

How does sequential search examine a list?

Back

A sequential search checks elements one at a time until it finds the target or reaches the end.

11
Front

What does −1 indicate in findIndex?

Back

A sequential search returns −1 when the target is not found.

12
Front

What is the worst-case time of sequential search?

Back

Sequential search has O(n) worst-case time because it may inspect every element in a list of length n.