1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
Revise later
SpaceTo flip
If confident
All Flashcards
What are the differences between `append()` and `insert()`?
`append()`: Adds to the end | `insert()`: Adds at a specific index.
What are the differences between `for` and `while` loops for list traversal?
`for` loop: Iterates through elements directly | `while` loop: Requires manual index management.
What are the differences between complete and partial traversal?
Complete: Visits all elements | Partial: Visits a subset of elements.
What are the differences between accessing and assigning list elements?
Accessing: Retrieves the value at an index | Assigning: Modifies the value at an index.
What are the differences between lists in Python and AP Pseudocode?
Python: Indexing starts at 0 | AP Pseudocode: Indexing starts at 1.
What are the differences between `remove()` and assigning `None` to a list element?
`remove()`: Changes the length of the list | Assigning `None`: Keeps the list length the same but replaces the element with `None`.
What are the differences between modifying a list in-place versus creating a new list?
In-place: Changes the original list | New list: Creates a copy with modifications, leaving the original unchanged.
What are the differences between a list and a string?
List: Mutable, can hold different data types | String: Immutable, holds characters only.
What are the differences between using a list and a set?
List: Ordered, allows duplicates | Set: Unordered, does not allow duplicates.
What are the differences between linear search and binary search?
Linear search: Works on unsorted lists, checks each element one by one | Binary search: Requires sorted list, divides search interval in half.
How do you access an element in a list?
Using its index: `list_name[index]`.
How do you change the value of an element in a list?
Assign a new value to the element at its index: `list_name[index] = new_value`.
How do you insert an element into a list?
Use the `insert()` method: `list_name.insert(index, value)`.
How do you add an element to the end of a list?
Use the `append()` method: `list_name.append(value)`.
How do you remove an element from a list?
Use the `remove()` method: `list_name.remove(value)`.
How do you determine the number of elements in a list?
Use the `len()` function: `len(list_name)`.
Explain complete list traversal.
Iterating through every element of the list, typically using a `for` or `while` loop.
Explain partial list traversal.
Iterating through a specific portion of the list, defined by start and end indices.
Describe the efficiency of linear search.
Simple to implement but inefficient for large lists, as it checks each element sequentially.
How does indexing work in Python lists?
Indexing starts at 0 for the first element.
What is a list?
A collection of elements, ordered and mutable.
What is an index?
The position of an element within a list.
What is list traversal?
The process of accessing each element in a list.
What is appending?
Adding an element to the end of a list.
What is inserting?
Adding an element at a specific index in a list.
What is removing?
Deleting an element from a list.
What does `len()` do?
Returns the number of elements in a list.
What is linear search?
Checking each element one by one until the desired element is found.
What is a complete traversal?
Going through every single element in the list.
What is a partial traversal?
Going through only a part of the list.