1.4.2 Data Structures

Cards (82)

  • What is an array?
    An ordered, finite set of elements
  • What is a one-dimensional array also known as?
    A linear array
  • How are arrays indexed by default?
    Zero-indexed
  • What is the output of print(oneDimensionalArray[3]) for the array [1, 23, 12, 14, 16, 29, 12]?
    14
  • How can a two-dimensional array be visualized?
    As a table or spreadsheet
  • In a two-dimensional array, how do you search for a position?
    Go down rows then across columns
  • What is the syntax to access an element in a three-dimensional array?
    threeDimensionalArray[z,y,x]
  • What is the output of print(threeDimensionalArray[0,1,2]) for the array [[[12,8],[9,6,19]],[[241,89,4,1],[19,2]]]?

    19
  • What is a record commonly referred to as?
    A row in a file
  • What are records made up of?
    Fields
  • How can fields in a record be accessed?
    Using recordName.fieldName
  • What is a list?
    A data structure of ordered items
  • How do lists differ from arrays?
    Lists can store non-contiguous items
  • What is the output of List.isEmpty() if List = [23, 36, 62, 49 , 23, 29, 12]?
    False
  • What does List.append(value) do?
    Adds a new value to the end
  • What does List.remove(value) do?
    Removes the first occurrence of value
  • What does List.length() return?
    The length of the list
  • What is a tuple?
    An ordered set of immutable values
  • How are tuples initialized?
    Using regular brackets
  • What happens if you try to change a tuple's value?
    It results in a syntax error
  • What is a linked list?
    A dynamic data structure for sequences
  • What does each node in a linked list contain?
    A data field and a pointer field
  • What is the purpose of the pointer field in a linked list?
    To link to the next item
  • How do you traverse a linked list?
    Start at the 'Start' pointer
  • What is an advantage of using linked lists?
    Values can be easily added or removed
  • What is a disadvantage of linked lists?
    They waste memory due to pointers
  • What is a graph?
    A set of vertices connected by edges
  • What is a directed graph?
    Edges can only be traversed one way
  • What is an adjacency matrix?
    A matrix representing graph connections
  • What is a stack?
    A last in first out (LIFO) structure
  • How are items added to a stack?
    Only at the top of the stack
  • What is a common use of stacks?
    To reverse an action
  • What is the preferred implementation for static stacks?
    When maximum size is known
  • What is the role of a pointer in a stack?
    Points to the top of the stack
  • What are the main operations that can be performed on a stack?
    • Push: Add an item to the top
    • Pop: Remove the top item
    • Peek: View the top item without removing it
  • What are the advantages of using an adjacency matrix?
    • Quick access times
    • Easy to add nodes
  • What are the advantages of using an adjacency list?
    • More space efficient for large, sparse networks
  • What are the strengths and weaknesses of linked lists?
    Strengths:
    • Dynamic size
    • Easy to add/remove items

    Weaknesses:
    • More memory required
    • Cannot access items directly
  • What is the data structure type of a stack?
    Last in first out (LIFO)
  • How do items get added or removed from a stack?
    Only from the top of the stack