5 data structures-queue

2
Queue • List of items in the order they were added • Only two operations – Add (enqueue, push) – Remove (dequeue, pop) • Adding an item adds it to the end of the queue • Removing an item removes it from the front of the queue • This makes a queue first-in- first-out (FIFO)

Transcript of 5 data structures-queue

Page 1: 5 data structures-queue

Queue

• List of items in the order they were added• Only two operations– Add (enqueue, push)– Remove (dequeue, pop)

• Adding an item adds it to the end of the queue

• Removing an item removes it from the front of the queue

• This makes a queue first-in-first-out (FIFO)

Page 2: 5 data structures-queue

Queue

• Add

• Remove

12

Next

Head 43

Next

65

Next

23

NextTail

12

Next

Head 43

Next

65

Next

23

NextTail

33

Next

12

Next

Head 43

Next

65

Next

23

NextTail

33

Next