Data structures: arrays, records, lists, tuples

Cards (41)

  • What is a data structure?
    A way to organize and manage data
  • What is the purpose of a record in data structures?
    To store multiple fields like name and age
  • How is an array described in terms of data structure?
    Like a numbered list for ordered data
  • What are the types of data structures mentioned?
    • Array
    • Record
    • List
    • Tuple
  • What is a list in the context of data structures?
    A structure that holds items in any order
  • How do arrays and lists differ in data structure usage?
    Arrays store ordered data, lists allow any order
  • How is a tuple defined in data structures?
    A fixed set of values ensuring data doesn't change
  • What is the main characteristic that distinguishes a tuple from a list?
    A tuple has a fixed set of values
  • What are the key characteristics of arrays?
    • Ordered storage
    • Direct access using index
    • Fixed size
    • Homogeneous data
  • What is an array?
    A data structure storing elements in sequence
  • How are elements stored in an array?
    In a specific order
  • What is the purpose of a record (struct)?
    To group related pieces of information
  • What is a common feature of the size of an array?
    It is usually fixed
  • What does direct access in arrays allow you to do?
    Access any element using its index
  • What is another name for a record in programming?
    Struct
  • What identifies each element in an array?
    An index
  • How would you access the first element of the array [85, 92, 78, 95, 80]?
    Using index 0
  • How does the fixed size of an array affect its usage?
    Limits the number of elements it can store
  • What does the field name `age` represent in the student record?
    The student's age
  • How would you define a student's profile using a record?
    • Use field names for attributes
    • Example:
    ```
    student = {
    name: "Alice",
    age: 18,
    grade: 95
    }
    ```
  • What type of data do most arrays store?
    Homogeneous data
  • How does a record differ from an array?
    Records use field names, arrays use indices
  • What does the field name `grade` represent in the student record?
    The student's grade percentage
  • What does the append operation do in a list?
    Adds an item to the end of the list
  • How can you access a specific field in a record?
    Using the syntax `record.fieldName`
  • What does the remove operation do in a list?
    Deletes an item by its value
  • What does a record use to access specific information?
    Field names
  • How does the index operation function in a list?
    Retrieves an item using its position
  • What does it mean for a list to have a dynamic size?
    You can add or remove items easily
  • What are the key characteristics of tuples?
    • Ordered storage
    • Direct access via index
    • Fixed size
    • Can hold different data types
  • What is a tuple in programming?
    An ordered collection of elements
  • What is a list in programming?
    A data structure that stores elements in sequence
  • What are the characteristics of a list?
    Ordered, mixed data types, dynamic size
  • What does it mean that a tuple is immutable?
    Its contents cannot be changed once created
  • What is the purpose of the pop operation in a list?
    Removes an item from the end of the list
  • Can a tuple hold different data types?
    Yes, it can hold different data types
  • How do you define a tuple in Python?
    Using parentheses, e.g., (1, "hello")
  • What will happen if you try to add an element to a defined tuple?
    An error will occur
  • How does the insert operation work in a list?
    Adds an item at a specific position
  • How does a tuple differ from a list in Python?
    Tuples are immutable, while lists are mutable