数据结构复习4.StackQueue

xiaoxiao2021-02-28  82

一·. Stack

LIFO后进先出。

(1)方法

push();

pop();

peek();

isEmpty();

(2)实现

用ArrayList,LinkedList均可实现

入出栈复杂度均为O(1)

二.队列

FIFO先进先出,Front、last出,Back、frist进

(1)方法

enqueue

dequeue

peekFront

isEmpty

(2)实现

用ArrayList(成为ArrayDeque),LinkedList均可实现

ArrayList实现时,判断的是Front和Back的位置,两者大小关系任意,两者连续时,说明队列已满。

三.关系

LinkedList 实现了List接口

                  实现了DeQueue接口 实现了Queue接口

ArrayList 实现了List接口

ArrayDeque 实现了DeQueue接口 实现了Queue接口

转载请注明原文地址: https://www.6miu.com/read-30646.html

最新回复(0)