Chap 4_Stacks and Queues

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play

1/17

encourage image

There are no tags or description

Looks like no tags are added yet.

18 Terms

1
New cards

Stacks

A ___ is a linear data structure in which elements are inserted and removed from the same end, called the top. It follows the Last In, First Out(LIFO) principle.

2
New cards

Queues

A ___ is a linear data structure in which elements are inserted at the rear and removed from the front. It follows the First In, First Out (FIFO) principle.

3
New cards

Stack Operations

push (), pop(), peek () / top (), isEmpty ()

4
New cards

push ()

Add element x to the top of the stack

5
New cards

pop ()

Remove and return the element at the top

6
New cards

peek () / top ()

Return the top element without removing it

7
New cards

isEmpty ()

Check whether the stack has any elements

8
New cards

Queue Operation

enqueue (), dequeue (), front (), isEmpty ()

9
New cards

enqueue ()

Add element x to the rear of the queue

10
New cards

dequeue ()

Remove and return the element at the front

11
New cards

front ()

Return the front element without removing it

12
New cards

isEmpty ()

Check whether the queue has any elements

13
New cards

Circular Queue

A ____ is an array-based queue wheere the front and rear indices wrap around to the beginning once they reach the end, reusing freed slots instead of shifting elements

14
New cards

Deque

A ___ allows insertion and deletion at both ends — front and rear. It generalizes both the stack (use one end only) and queue (use both ends in FIFO order)

15
New cards

insertFront ()

Add x to the front

16
New cards

insertRear ()

Add x to the rear

17
New cards

deleteFront ()

Remove from the front

18
New cards

deleteRear ()

Remove from the rear