DS&A
# stack
FILO
push peek/ pop
uses of stacks
- unde/redo features in text editors
- moving back/forward though brower history
- backtracking algorithms(maze file directories)
- calling functions(call stack)
# Queue
FIFO
add enqueue offer / remove dequeue poll
- keyboard buffer(letters should appear on the screen in the order they’re pressed)
- printer queue (print jobs should be completed in order)
- used in LinkedLists, priorityQueues, Breath-first search
# PriorityQueue
a FIFO data structure that serves element with the highest priorities first before elements with lower priority
# Linked List
- Single linked list
- doule linked list
Advantage
- Dynamic data structure (allocates needed memory while running)
- Insertion and deletion of nodes is easyO(1)
- NO/Low memory Waste
Disadvantage
- Greater memory usage(additional pointer)
- No random access of elements (no index [i])
- Accessing searching elements is more time consuming O(n)
uses
implements stack/queue
GPS navigation
music playlist
# Array
static / dynamic
Advantage
- random access of elements O(1)
- Good locality of reference and data cache utilization
- Easy to insert/delete at the end
Disadvantage
- wastes more memory
- shifting elements is time consuming O(n)
- Expanding/Shrinking the array is time consumingO(n)
上次更新: 2025/03/09, 15:45:50