Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
62 views

Data Structure and Algorithm

The document discusses various data structures and algorithms including queues, stacks, linked lists, arrays, and search and sorting algorithms. It provides details on common operations and time complexities. Key points covered include: - Queues follow FIFO order and are useful for buffering like print queues - Stacks follow LIFO order and are used for functions calls and undo/redo - Linked lists store nodes with data and pointers between non-contiguous memory - Common search algorithms are linear search and binary search - Common sorting algorithms have time complexities of n, n log n, or n^2

Uploaded by

jhannriels
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
62 views

Data Structure and Algorithm

The document discusses various data structures and algorithms including queues, stacks, linked lists, arrays, and search and sorting algorithms. It provides details on common operations and time complexities. Key points covered include: - Queues follow FIFO order and are useful for buffering like print queues - Stacks follow LIFO order and are used for functions calls and undo/redo - Linked lists store nodes with data and pointers between non-contiguous memory - Common search algorithms are linear search and binary search - Common sorting algorithms have time complexities of n, n log n, or n^2

Uploaded by

jhannriels
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Topics Covered: Queue : FIFO data structure.

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

small data set: LinkedList = BAD


large data set + lots of searching:
LinkedList = BAD
large data set + lots of
inserting/deleting: LinkedList = GOOD

ArrayList : is a re-sizable array, also


called a dynamic array. It grows its size
to accommodate new elements and
shrinks the size when the elements
are removed. ArrayList internally uses
an array to store the elements.
Linear Search : Iterate through a collection
one element at a time.
Disadvantages :
 Slow for large data set
Advantages :
 fast for searches of small to medium
data sets
 does not need to sorted
 useful for data structures that do not
have random access (Linked List)

0(1) = constant time Binary Search : search algorithm that finds


the position of a target value within a
 Random access of an element in
sorted array. Half of the array is eliminated
an array
during each “step“.
 Inserting at the beginning of
linkedlist
0(log n) = logarithmic time
 Binary search
0(n) = linear time
 Looping through elements in an array
 Searching through a linkedlist
0(n log n) = quasilinear time
 Quicksort
 Mergesort
 Heapsort
0(n^2) = quadratic time
 Insertion sort
 Selection sort
 Bubblesort
0(n!) = factorial time
 Travelling salesman problem

You might also like