Data Structure and Algorithm
Data Structure and Algorithm
Data Structure and Algorithm
First-In
First-Out. A collection design for
1. Basic Data Structures
holding elements prior processing
2. Big O Notation linear data structure.
3. Searching algorithms
add = enqueue, offer()
4. Sorting algorithms
5. Graphs remove = dequeue, poll()
6. Trees
Where are queues useful?
Data Structure : a named location 1. Keyboard Buffer (letters should appear
on the screen in the order they're pressed)
that can be used to store and
organize data. 2. Printer Queue (Print jobs should be
completed in order)
3. Used in LinkedLists, PriorityQueues,
Algorithm : a collection of steps Breadth-first search
to solve a problem.
Priority Queue : a FIFO data
structure that serves elements
stack : a LIFO data structure. Last- with the highest priorities first
In First-Out stores objects into a before elements with lower
sort of “vertical tower” priority.
push() to add to the top.
pop() to remove from the top. LinkedList : stores Nodes in 2
parts (data + address) Nodes are
Uses of stacks? in non-consecutive memory
1. undo/redo features in text editors locations.
2. moving back/forward through browser history
Elements are linked using
3. backtracking algorithms (maze, file directories)
pointers.
4. calling functions (call stack)
Advantages? Big O Notation : “how code slows as
data grows.”
1. Dynamic Data Structure
( allocates needed memory while
running). 1. Describes the performance of an
2. Insertion and Deletion of Nodes algorithm as the amount of data
is easy. 0(1) increases.
3. No/Low memory waste. 2. Machine independent(# of steps
to completion)
Uses? 3. Ignore smaller operations 0(n+1)
1. Implements stacks/Queues -> 0(n)
2. GPS Navigation
3. Music Playlist