From charlesreid1

Main abstract data types:

  • Lists
  • Maps/Dictionaries
  • Sets
  • Stacks
  • Queues
  • Trees

These are basic types of data structures (although some of the data types above may utilize other data types in their implementation, e.g., a linked list structure used to store a dictionary).

Lists

Array list data type

Dynamically expanding array list type. The best way to implement a dynamically expanding array is to have it double in size when the array of capacity n reaches n+1 items. Increasing by a fixed amount incurs an O(n^2) cost.

We also want to dynamically shrink the array, but at a different multiple than 1/2 (otherwise we have a single size change that can toggle the size of the array, incurring O(n) cost with each operation.)

Array list interface

The array list type should implement the following methods:

  • search
  • append/insert
  • remove/pop
  • get
  • minimum
  • maximum

Array list computational complexity

Operation Array list Array list, sorted
Search(L,k) O(n) O(log n)
Insert(D,x) O(1) O(n)
Delete(L,x) O(1)* O(n)
Successor(L,x) O(n) O(1)
Predecessor(L,x) O(n) O(1)
Minimum(L) O(n) O(1)
Maximum(L) O(n) O(1)

Linked list data type

Linked data structures: much/most of the data in a linked list data type is dedicated to links/addresses

Main differences in implementation of linked list types are in the links themselves. Doubly linked lists have simpler algorithms and are easier to implement, but come with the extra overhead of additional pointers.

Speed of operations on sorted and unsorted linked lists:

Operation Singly Linked List Doubly Linked List Singly Linked List, Sorted Doubly Linked List, Sorted
Search(L,k) O(n) O(n) O(n) O(n)
Insert(D,x) O(1) O(1) O(n) O(n)
Delete(L,x) O(n)* O(1) O(n)* O(1)
Successor(L,x) O(n) O(n) O(1) O(1)
Predecessor(L,x) O(n) O(n) O(n)* O(1)
Minimum(L) O(n) O(n) O(1) O(1)
Maximum(L) O(n) O(n) O(1)* O(1)

Map/Dictionary

Dictionary data type

Flags