Algorithms and Data Structures
(CSC112)
Handout -1
Introduction to Algorithms and Data Structures
Algorithms and Data Structures
Static Data Structures
Searching Algorithms
Sorting Algorithms
List implementation through Array
ADT: Stack
ADT: Queue
Dynamic Data Structures (Linear)
Linked List (Linear Data Structure)
Dynamic Data Structures (Non-Linear)
Trees, Graphs, Hashing
3 steps in the study of data structures
Logical or mathematical description of the structure
Implementation of the structure on the computer
Quantitative analysis of the structure, which includes determining the amount of memory
needed to store the structure and the time required to process the structure
Lists (Array /Linked List)
Items have a position in this Collection
Random access or not?
Array Lists
internal storage container is native array
Linked Lists
public class Node
{
private Object data;
private Node next;
Stacks
Collection with access only to the last element inserted
Last in first out
insert/push
remove/pop
top
make empty
Queue
Trees
Similar to a linked list
public class TreeNode
{
private Object data;
private TreeNode left;
private TreeNode right;
Hash Tables
Take a key, apply function
f(key) = hash value
store data or object based on hash value
Sorting O(N), access O(1) if a perfect hash function and enough memory for table
how deal with collisions?
-----------------------------------------------