Data types

Cards (16)

  • Arrays
    • Represented as a singular row, with data one after the other
    • Immutable - once intialised, you cannot change it
    • Consists of only one data type
  • Pseudocode for array
    For i in range (#)
  • 2D arrays
    • Represented as a table with rows and columns
    • Left-right = i
    • Up-down = j
  • Pseudocode for 2D array
    1. For i in range (column #)
    2. For j in range (row #)
  • Lists
    • Mutable - can add, remove or update data
    • Consists of one type of data
  • Tuples
    • Immutable - once data is initialised, data cannot be adjusted
    • Can consist of more than one data type
  • Records (database)

    • Mutable - data can be edited (added, removed, updated)
    • Is structured
    • Uses a fixed data type, using fields
    • Having multiple records, would result in a table
  • Linked list
    • Consists of data and pointer
    • The data stored the data and the pointer points to the next item
    • If you were to add a new location after the second location: Create a new item of the new location, Traverse (travel) to the second item, Update the pointer of the second item so that it is now pointing to the new location, Make the new location point to the location that location two was initially pointing to
    • Removing items: traverse to the item you want to remove, Redirect the pointers pointing to this item, so that it's now pointing to next item
  • Trees
    • Root
    • Branches/links
    • Nodes
    • Leaf (has no branches)
    • Parent/child relationships
    • Flows in one direction (from parent to child)
  • Binary tree
    • Max 2 child per parent
    • Left < parent
    • Right > parent
    • Uses Binary search
  • Traverse tree - Breadth
    Row of nodes listed on a balanced tree, starting from the root to the leaf
  • Post-order
    1. Dot on the right side of each node and tree is traced, starting from the root, to the left
    2. Also known as back tracking as the nodes are being tracked in the order: left, right, bottom up
  • Array structure
  • 2D Array structure
  • Eg of Tuples
  • 2 ways which linked lists can be displayed