Cards (83)

  • What is a list in computer science?
    Ordered collection of elements
  • The example `[1, 2, 3, "hello"]` demonstrates a list containing integers and a string
  • Elements in a list are stored in a specific sequence.
  • How are elements in a list accessed?
    By their index
  • Lists in programming are mutable, meaning their elements can be modified.
  • A list can only contain elements of the same data type.
    False
  • From which index do list elements start in most programming languages?
    0
  • Lists in computer science are heterogeneous, allowing elements of different data types.
  • Match the characteristic of a list with its description:
    Ordered ↔️ Elements are stored in a specific sequence
    Indexable ↔️ Elements can be accessed by their index
    Mutable ↔️ Elements can be added, removed, or modified
    Heterogeneous ↔️ Can contain elements of different data types
  • What type of list maintains the order in which elements are inserted?
    Ordered list
  • Unordered lists do not maintain a specific order
  • Nested lists can contain other lists as elements.
  • What is an example of a nested list in Python?
    [[1, 2], [3, 4]]
  • Ordered lists maintain the insertion order
  • Unordered lists maintain a specific order.
    False
  • Nested lists are lists within lists
  • Match the list type with its ordering feature:
    Ordered Lists ↔️ Yes
    Unordered Lists ↔️ No
    Nested Lists ↔️ Depends on content
  • Are ordered lists mutable?
    Yes
  • Unordered lists are heterogeneous.
  • The mutability of nested lists depends on their content
  • What is the append operation used for in lists?
    Adding to the end
  • Inserting an element into a list requires specifying its index.
  • Accessing an element in a list requires using its index
  • What is a key feature of lists regarding element ordering?
    Elements are ordered
  • Lists are more flexible than arrays because they allow heterogeneous
  • What type of data do arrays require their elements to be?
    Homogeneous
  • Lists are indexed starting from 1.
    False
  • Lists store elements in a specific sequence
  • What does it mean for a list to be indexable?
    Elements can be accessed by index
  • Match the list type with its characteristics:
    Ordered ↔️ Maintains order
    Unordered ↔️ No specific order
    Nested ↔️ Contains lists within lists
  • What is the primary advantage of using arrays to implement lists?
    Direct access using indices
  • Inserting or deleting elements in the middle of an array requires shifting elements, resulting in O(n) complexity for the operation
  • Linked lists require additional memory for storing pointers.
  • What is an example of a database operation that uses lists?
    Fetching product details
  • Lists can be used to represent graphs by implementing adjacency lists
  • Why are lists suitable for storing dynamic data, such as a to-do list?
    They are mutable
  • Match the list application with its example:
    Database query results ↔️ Storing product details
    Implementing other data structures ↔️ Creating stacks and queues
  • What is an example of a real-world application of lists in e-commerce?
    A shopping cart
  • Lists have various applications due to their flexibility and ordered nature
  • Lists can store data that changes frequently, such as a to-do list.