Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Introduction to Data Structure and Algorithms Chuan-kai Yang Data Structures Basic Data Types Stack Queue Linked-List Array Heap, Priority Queue Binary Search Tree Hash Table Basic Data Types Character (Byte, Octet) Boolean Integer Signed or Unsigned Signed or Unsigned Long or short Float, double String Stack Interfaces (Allowed Operations) Push Pop If a stack is not full, this adds one element on the top of a stack If a stack is not empty, this removes one element from the top of a stack FILO (First In Last Out) Queue Interfaces Enqueue Dequeue If a queue is not full, add one element at the tail of a queue If a queue is not empty, remove one element from the head of a queue FIFO (First In First Out) Linked-List Singly-linked lists Doubly-linked lists Circular-linked lists Search, Insert, Delete Array 1 2 3 4 5 6 7 8 9 1 10 9 6 7 5 3 2 9 Heap Max_Extract, Insert, Delete Binary Search Tree Search, Insert, Delete, Successor, Predecessor Hash Table Hash Table – Chaining Hash Table – Open Addressing h1 ( k ) k mod13 h2 ( k ) 1 ( k mod11) Insert 14 Algorithms What is algorithm? Time Complexity & Space Complexity Growth of Functions Recurrence relation Sorting Searching Graph Algorithm Computational Geometry What is Algorithms Algorithm: Any well-defined computation procedure that takes some value, or set of values, as input and produces some value, or set of values, as output. Or: tool for solving well specific computational problem. Example: Sorting problem Input: A sequence of n numbers a1 , a2 ,..., a n ' ' ' a , a ,..., a Output: A permutation 1 2 n of the input sequence such that a1' a'2 ... a'n . Time & Space Complexity Time complexity Time to run an algorithm Worst-Case, Best-Case, Average-Case Space complexity (Memory) Capacity to run an algorithm Growth of Functions Log < polynomial < exponential Constant time: c Logarithmic time: log(n) Linear time: cn Quadratic time: cn2 Exponential time: cn Recurrence Relation merge_sort(A, p, q) { merge_sort(A, p, (p+q)/2); merge_sort(A, (p+q)/2+1, q); merge(A, p, q); } T(n)=2T(n/2)+O(n) Sorting Insertion Sort Selection Sort Quick Sort Counting Sort Searching Method Linear Search Binary Search Hash Search Finding what? If a data structure has some element Finding the n-th smallest element Finding the successor/predecessor Graph Algorithm Minimal Spanning Tree Shortest Path Euler Path/Cycle Hamiltonian path/Cycle Travelling salesman Minimal Spanning Tree Shortest Path Euler Path/Cycle Hamiltonian Path/Cycle Traveling-Salesman Problem Computational Geometry Line-segment intersection Convex hull Voronoi diagram Convex Hull Voronoi Diagram