y-xing01 / OOPCA5_YueXing

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OOPCA5_YueXing

ArrayList

  • Adding an item to an ArrayList in Java is O(1), but the worst case for an add operation in ArrayList is O(n)
  • Complexity: O(N)

Display ArrayList

  • Displaying a whole ArrayList in Java is O(N) as there could be ten or millions of object in an arrayList.
  • Complexity: O(N)

HashMap

  • With HashMap, we can achieve an average time complexity of O(1) for the put and get operations and space complexity of O(n).
  • Total time for insertion of n elements in a HashMap = n * O(1) = O(n)
  • Time Complexity: O(1)
  • Space Complexity: O(N)

TreeMap

  • TreeMap has complexity of O(logN) for insertion and lookup. TreeMap does not allow null key but allow multiple null values
  • Total time for insertion of n elements in a TreeMap = Log 1 + Log 2 + Log 3 + ... + Log (n-1) --> (n-1) * Log (n) --> O(logN)
  • Complexity: O(logN)

PriorityQueue

  • It will take O(log N) time to insert and delete each element in the priority queue.
  • Based on heap structure, priority queue also has two types max - priority queue and min - priority queue.
  • Complexity: O(logN)

Code View OOP CA5

Main APP Menu

input-onlinejpgtools

OOP CA5 Stage 1

APP Menu

input-onlinejpgtools (5)

Methods

input-onlinejpgtools (3)

OOP CA5 Stage 2

APP Menu

image

Methods

input-onlinejpgtools (6)

Feature 18 OOP CA5

image

About


Languages

Language:Java 100.0%