What is a list?
A list is an ordered sequence of elements stored under one name; an array may represent the same idea in some programming languages.
Study 07. Lists, Arrays, and Sequential Data with 12 free online flashcards. Review key terms, definitions, and concepts with this interactive flashcard deck.
What is a list?
A list is an ordered sequence of elements stored under one name; an array may represent the same idea in some programming languages.
What index identifies the first element in zero-based indexing?
The first element has index 0.
What are the valid indexes for a list of length n?
For a list of length n, the valid indexes usually range from 0 through n − 1.
What happens to list length when an existing element is updated?
Updating an existing element changes its value but does not necessarily change the list’s length.
When is value-based traversal appropriate?
Use value-based traversal when the program needs each value but does not need its position.
What is an accumulator?
An accumulator stores a result that is built during traversal, such as a total, count, average, or new collection.
What does filtering do to a collection?
Filtering keeps elements that satisfy a condition in a new list; the original list remains unchanged.
What does collection transformation produce?
Transformation creates a new value for each element. Doubling [2, 5, 7] produces [4, 10, 14].
How should a maximum search be initialized?
For a nonempty list, initialize the maximum with the first element, then compare the remaining elements.
How does sequential search examine a list?
A sequential search checks elements one at a time until it finds the target or reaches the end.
What does −1 indicate in findIndex?
A sequential search returns −1 when the target is not found.
What is the worst-case time of sequential search?
Sequential search has O(n) worst-case time because it may inspect every element in a list of length n.