Stack

  • "Last In, First Out" (LIFO)

  • push(element): Add element to the top of the Stack

    top(): Look at the element at the top of the Stack

    pop(): Remove the element at the top of the Stack

  • Use Deque to implement Stack

  • Same as queue, the back structure can be Linked List or Circular Array

  • How to use circular array to create a stack?

    Ans: Keep a int top, recording the index of the top element in stack
    
  • How to use Linked List to create a stack?

    Ans: Keep a pointer top, point to the top element in stack
    
  • DFS
REFERENCE: stepik 2.8

results matching ""

    No results matching ""