DSA chapter 5

0.0(0)
studied byStudied by 0 people
0.0(0)
full-widthCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/13

encourage image

There's no tags or description

Looks like no tags are added yet.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

14 Terms

1
New cards

queue

  • Data structure in which the first element put into the list is the first element we can take out (FIFO)

  • Elements are stored by order of insertion

  • Elements can only be added to the back

  • Only the first element can be accessed/removed

2
New cards

goal of queue

Every operation on a queue should be O(1)

3
New cards

operations on a queue

  • Offer or enqueue

  • Remove or dequeue

  • Peek

  • Clear all elements/Initialize()

  • isEmpty()

  • getSize()

  • isFull()

  • display()

4
New cards

enqueue operation

Operation of adding a new element at the rear

5
New cards

dequeue operation

Operation of taking the element in the front of a queue

6
New cards

array-implementation of queue

  • Keeps track of the number of items in the queue size and the index of the first & last element

  • When an element is dequeued, the size is decremented and first changes

  • When an element is queued, the size is incremented and the last changes too

7
New cards

circular array implementation of queue

  • A problem with simple arrays is we run out of space even if the queue never reaches the size of the array

  • This implementation of queue can be used to solve this problem because freed spaces are re-used to store data

  • If we reach the end of the array, the new element goes at the front of the array (if that spot isn’t already used)

8
New cards

linked list implementation of queue

A queue implemented with both a head(start) and tail(end) pointer

9
New cards

deque

  • Double-ended queue

  • Insertion and deletion can occur at either end

  • Implementation similar to that of queue

  • Best implemented using doubly linked list

10
New cards

basic operations of deque

  • EnqueueFront

  • DequeueFront

  • EnqueueRear

  • DequeueRear

11
New cards

priority queue

  • Queue where each data has an associated key provided at time of insertion

  • Dequeue operation deletes data having highest priority in the list

12
New cards

demerging queues

  • The process of creating two or more queues from a single queue

  • Used to give priority for some groups of data

13
New cards

merging queues

  • The process of creating a priority queue from two or more queues

  • The ordinary dequeue implementation can be used to delete data in the newly created priority queue

14
New cards

application of queues

  1. Access to shared resources (ex. printer)

  2. Disk Driver (queue of disk I/O requests)

  3. Task scheduler in multiprocessing system (priority queues of processes)

  4. Telephone calls in busy environment (queue of telephone calls)

  5. Simulation of waiting line (queue of people)