| | | | | |

Exploring Implementation Possibilities - 1

  • List < pair < KeyType , DataType > >
    • use List<pair> as container
    • Insert(), Remove(), Retrieve() use sequential search
    • Insert(): search, then PushBack() if not found
    • Insert(), Remove(), Retrieve() runtimes are O(size)
  • Sorted vector < pair < KeyType , DataType > >
    • Use Vector <pair> as container
    • Maintain order by key (first element of pair)
    • Use binary search for lookup
    • Insert() and Remove() runtime O(size)
    • Retrieve() runtime O(log size)
  • Vector < DataType >
    • assumes key is unsigned int
    • random access: V[key] = data
    • runspace = O(2s), where s = size of largest key
  • Set < KeyType , DataType >
    • No special assumptions on KeyType
    • All operations Θ(log n)
    • runspace overhead reasonable
    • ordered traversal included!

| | Top of Page | 8. Hash Tables and Associative Arrays - 3 of 17