arraylist,

ArrayList

  • resize function:
    1. int [] data = new int[0];
    2. int [] newdata = new int [data.length * 2 + 1];
    3. data = new data
  • realization : 00:20:57

time complexity

  • executing time cost and input scale (worst case analysis)

maintaining cost and using cost

  • Unsorted data structrue has low maintaining cost, but higher using cost, like linked list;
  • Sorted data structrue has high maintaining cost, but high lower using cost, you can find any element by index, like sorted array

Stack

  • Last in First Out (LIFO)
  • low maintaining cost

Operation :Build-in java function

  1. (add)push
  2. (removw)pop
  3. (get)peek
  4. isEmpty
  5. empty

realization

  • using arraylist: find the basic data structure function and the realized data structure function rationship
  • Using LinkedList: add element as head, it is a better way to realize stack by linked list, time complexity is smaller

Queue

  • First in First out (FIFO)
  • LinkedList to realize
  • queue in System: message Queue

Operation : Build-in Java function

  1. enqueue
  2. dequeue

example of using

  • stack
    • match paretheses
arraylist linked list stack BST
add(head) O(n) O(1) O(log(n)
add(tail) O(1) O(n)
get O(1) O(n)