Quick Data Structure Revision

1. ArrayList - Useful for storing data with no unique constraints and unknown size of data set.
Time Complexity:

  1. Writing - O(1)
  2. Reading - O(1)
  3. Searching - O(N)
  4. Deleting - O(N)
2. Array - Useful for storing data with fixed data set. Generally faster than HashSets and ArrayLists. Vast usage of arrays includes: Storing of data, storing count of data, sorting data and binary searching.

Time Complexity:

  1. Writing - O(1)
  2. Reading - O(1)
  3. Searching - O(1)
  4. Deleting - O(N)
3. HashSet - Useful for storing unique values of a data set.
Time Complexity:

  1. Writing - O(1)
  2. Reading - O(1)
  3. Searching - O(1)
  4. Deleting - O(1)
4. HashMap - Useful for storing unique keys and its values. Values can be any data type of data structure.
Time Complexity:

  1. Writing - O(1)
  2. Reading - O(1)
  3. Searching - O(1)
  4. Deleting - O(1)
5. TreeSet - A Tree Set is a sorted HashSet. The java interpretation includes functions such as TreeSet.ceiling and TreeSet.floor which gets the closest values of the given value.
Time Complexity:

  1. Writing - O(logN)
  2. Reading - O(logN)
  3. Searching - O(logN)
  4. Deleting - O(logN)
6. TreeMap - A Tree Map is a sorted HashMap. The java interpretation includes functions such as TreeMap.ceiling and TreeMap.floor which gets the closest values of the given value.
Time Complexity:

  1. Writing - O(logN)
  2. Reading - O(logN)
  3. Searching - O(logN)
  4. Deleting - O(logN)
7. PriorityQueue - A priority queue can be given a comparator condition to sort the data set. It performs as a priority heap.
Time Complexity:

  1. Writing - O(logN)
  2. Reading - O(logN)
  3. Searching - O(logN)
  4. Deleting - O(logN)
8. LinkedList - A LinkedList is a continuous form a linked data structure.
Time Complexity:

  1. Writing - O(1)
  2. Reading - O(N)
  3. Searching - O(N)
  4. Deleting - O(1)
9. Queue/ArrayDequeue - FIFO data set. Useful for BFS.
Time Complexity:

  1. Writing - O(1)
  2. Reading - O(1)
  3. Searching - O(1)
  4. Deleting - O(1)
10. Stack - LIFO data set. Useful for DFS.
Time Complexity:

  1. Writing - O(1)
  2. Reading - O(1)
  3. Searching - O(1)
  4. Deleting - O(1)
11. Binary Tree - A parent-child data structure where each parent has exactly 2 or less children.
Time Complexity:

  1. Writing - O(1)
  2. Reading - O(1)
  3. Searching - O(N)
  4. Deleting - O(N)
12. Binary Search Tree - A parent-child data structure where each parent has exactly 2 or less children where the left child is lesser than or equal to the parent and the right child is more than or equal to the parent.
Time Complexity:

  1. Writing - O(1)
  2. Reading - O(1)
  3. Searching - O(logN)
  4. Deleting - O(logN)
13. Graph - A connected data structure where each node can have any number of neighbors.
Time Complexity:

  1. Writing - O(N)
  2. Reading - O(N)
  3. Searching - O(N)
  4. Deleting - O(N)
14. Weighted Graph/Adjacency Matrix - A connected data structure where each node can have any number of neighbors and the distance between two nodes have a cost.
Time Complexity:

  1. Writing - O(N)
  2. Reading - O(N)
  3. Searching - O(N)
  4. Deleting - O(N)

Popular posts from this blog

Building your first Phonegap android application with HTML and JavaScript