CC4 - F - QUEUES & SORTING Flashcards
- is a special type of LinkedList.
- It is a FIFO (First-in, First-out) data structure.
Queue
Describe the Queue
- (x) middle removal
- (/) head deletion
- (/) end insertion
3 main operations of Queue
- EnQueue
- DeQueue
- Peek
adds an element to the end of the queue;
Enqueue
removes the first element in the queue;
dequeue
returns the first element without removing it, just like in a stack.
peek
- an insertion must happen at one end that we call rear or tail of the queue and any removal must happen at the other end called
front or end of the queue
Queue
- A List or collection with the restriction that insertion can be performed at one end (rear) and deletion can be performed at the other end (front)
Queue ADT
Queue operations
- oEnQueue(x)
- DeQueue()
- Front()
- IsEmpty()
T/F Array based vs. Linked Queues
All member functions for both the array-based and linked queue implementations require different time
Flase: constant time
T/F Array based vs. Linked Queues
The space comparison issues are the same as for the equivalent stack implementations.
true
T/F Array based vs. Linked Queues
Unlike the array-based stack implementation, there is no convenient way to store one queues in the same array, unless items are always transferred directly from one queue to the other.
False: one queue is to one array
- Given a list of data find the location of a particular value or report that value is not present
- linear search
- if items are unsorted, this approach is necessary
Searching
- If items are sorted then we can divide and conquer
- dividing your work in half with each step
ogenerally a good thing
Searching in a Sorted List
– The data collection to be sorted is kept in the main memory.
Internal Sorting