HKOI 2005 Training Introduction to Algorithms Alan, Tam Siu Lung.

Slides:



Advertisements
Similar presentations
MATH 224 – Discrete Mathematics
Advertisements

Lecture 12: Revision Lecture Dr John Levine Algorithms and Complexity March 27th 2006.
S. J. Shyu Chap. 1 Introduction 1 The Design and Analysis of Algorithms Chapter 1 Introduction S. J. Shyu.
Divide-and-Conquer Recursive in structure –Divide the problem into several smaller sub-problems that are similar to the original but smaller in size –Conquer.
ALGORITHMS Introduction. Definition Algorithm: Any well-defined computational procedure that takes some value or set of values as input and produces some.
CS333 Algorithms
Data Structures & Algorithms What The Course Is About s Data structures is concerned with the representation and manipulation of data. s All programs.
CSE 830: Design and Theory of Algorithms
1 Data Structures A program solves a problem. A program solves a problem. A solution consists of: A solution consists of:  a way to organize the data.
CSE 830: Design and Theory of Algorithms Dr. Eric Torng.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 22 Instructor: Paul Beame.
Chapter 11 Limitations of Algorithm Power Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Analysis of Algorithms 7/2/2015CS202 - Fundamentals of Computer Science II1.
Lecture 30 CSE 331 Nov 10, Online Office Hours
© 2006 Pearson Addison-Wesley. All rights reserved10 A-1 Chapter 10 Algorithm Efficiency and Sorting.
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
Introduction to Algorithm design and analysis
Data Structure & Algorithm Lecture 3 –Algorithm Analysis JJCAO.
Analysis of Algorithms Spring 2015CS202 - Fundamentals of Computer Science II1.
1 Summary of lectures 1.Introduction to Algorithm Analysis and Design (Chapter 1-3). Lecture SlidesLecture Slides 2.Recurrence and Master Theorem (Chapter.
Instructor: Dr. Sahar Shabanah Fall Lectures ST, 9:30 pm-11:00 pm Text book: M. T. Goodrich and R. Tamassia, “Data Structures and Algorithms in.
Teaching Teaching Discrete Mathematics and Algorithms & Data Structures Online G.MirkowskaPJIIT.
CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a lgorithms.
Computational Complexity Polynomial time O(n k ) input size n, k constant Tractable problems solvable in polynomial time(Opposite Intractable) Ex: sorting,
Discrete Mathematics Algorithms. Introduction  An algorithm is a finite set of instructions with the following characteristics:  Precision: steps are.
2.3 Functions A function is an assignment of each element of one set to a specific element of some other set. Synonymous terms: function, assignment, map.
Lecture 2 Computational Complexity
INTRODUCTION TO THE THEORY OF COMPUTATION INTRODUCTION MICHAEL SIPSER, SECOND EDITION 1.
CHAPTER 09 Compiled by: Dr. Mohammad Omar Alhawarat Sorting & Searching.
Chapter 3 Sec 3.3 With Question/Answer Animations 1.
Introduction to HKOI. Self Introduction Ice Breaking Game.
Algorithms Lecture 1. Introduction The methods of algorithm design form one of the core practical technologies of computer science. The main aim of this.
Introduction to Algorithms Lecture 1. Introduction The methods of algorithm design form one of the core practical technologies of computer science. The.
ECOE 456/556: Algorithms and Computational Complexity Lecture 1 Serdar Taşıran.
1 COMP3040 Tutorial 1 Analysis of algorithms. 2 Outline Motivation Analysis of algorithms Examples Practice questions.
© 2011 Pearson Addison-Wesley. All rights reserved 10 A-1 Chapter 10 Algorithm Efficiency and Sorting.
TECH Computer Science NP-Complete Problems Problems  Abstract Problems  Decision Problem, Optimal value, Optimal solution  Encodings  //Data Structure.
Analysis of algorithms Analysis of algorithms is the branch of computer science that studies the performance of algorithms, especially their run time.
Brief Introduction of Algorithm. What is Algorithm A method with several definite steps to effectively complete a task. In general, it starts from the.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
1 Lower Bounds Lower bound: an estimate on a minimum amount of work needed to solve a given problem Examples: b number of comparisons needed to find the.
1Computer Sciences Department. Book: Introduction to Algorithms, by: Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest Clifford Stein Electronic:
1 CPSC 320: Intermediate Algorithm Design and Analysis July 28, 2014.
INTRODUCTION. What is an algorithm? What is a Problem?
CSE373: Data Structures & Algorithms Lecture 22: The P vs. NP question, NP-Completeness Lauren Milne Summer 2015.
CS223 Advanced Data Structures and Algorithms 1 Review for Final Neil Tang 04/27/2010.
Chapter 5 Algorithms (2) Introduction to CS 1 st Semester, 2015 Sanghyun Park.
Beauty and Joy of Computing Limits of Computing Ivona Bezáková CS10: UC Berkeley, April 14, 2014 (Slides inspired by Dan Garcia’s slides.)
HKOI Programming HKOI Training Team (Intermediate) Alan, Tam Siu Lung Unu, Tse Chi Yung.
LIMITATIONS OF ALGORITHM POWER
Design and Analysis of Algorithms (09 Credits / 5 hours per week) Sixth Semester: Computer Science & Engineering M.B.Chandak
CSE 340: Review (at last!) Measuring The Complexity Complexity is a function of the size of the input O() Ω() Θ() Complexity Analysis “same order” Order.
CES 512 Theory of Software Systems B. Ravikumar (Ravi) Office: 141 Darwin Hall Course Web site:
CES 592 Theory of Software Systems B. Ravikumar (Ravi) Office: 124 Darwin Hall.
Lecture. Today Problem set 9 out (due next Thursday) Topics: –Complexity Theory –Optimization versus Decision Problems –P and NP –Efficient Verification.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
Analysis of Algorithms Spring 2016CS202 - Fundamentals of Computer Science II1.
Conceptual Foundations © 2008 Pearson Education Australia Lecture slides for this course are based on teaching materials provided/referred by: (1) Statistics.
Advanced Algorithms Analysis and Design
Course Description Algorithms are: Recipes for solving problems.
Design and Analysis of Computer Algorithm (CS575-01)
Design and Analysis of Algorithms (07 Credits / 4 hours per week)
Objective of This Course
COSC 320 Advanced Data Structures and Algorithm Analysis
Teori Bahasa dan Automata Lecture 1: Course Overview and Introduction
Major Design Strategies
Course Description Algorithms are: Recipes for solving problems.
Department of Computer Science & Engineering
Design and Analysis of Algorithms (04 Credits / 4 hours per week)
Major Design Strategies
Presentation transcript:

HKOI 2005 Training Introduction to Algorithms Alan, Tam Siu Lung

What is Algorithm? Algorithm –A set of data manipulations instructions to solve a problem (informatics problem) Problem –A mapping from each input (in a specific format) to an output (in a specific format) Pseudo-Code –Realization of Algorithm in the current domain Mapping from problem input to algorithm input Mapping from algorithm output to problem output Program –Realization of Pseudo-Code given A compiler and the language supported Data in plain text format and the IO routines supported

Visualization of Program AB Algorithm1 Coding Pseudo-Code Source-Code int main() { A a = Read(); B b = Algorithm1(a); C c = Algorithm2(b); D d = Algorithm3(c); Write(d); } BC Algorithm2 CD Algorithm3

Algorithm Example Sorting Problem –Given an array of N comparable elements with comparable keys –Output a permutation of the elements –such that no element is has a key greater than that of the one there before Note –Array = a sequence of elements –Element = a key-value pair –Permutation =... –Greater than = …

Realization Example To print in sorted order a set of points in a cetacean plane by the distance from origin: Realization contains –Key = distance from origin –Value = coordinates = (x, y) –Comparison of 2 elements = comparison of the numerical values of distances Pseudo-Code contains –Store the set in an array –Sort them –Output the array in order

Why Algorithms? Computational Biology Database Cryptography Quantitative Analysis Artificial Intelligence Scheduling

Example – Multiple Sequence Alignment Input –GCTAGCTAAC –AACTAGC –AGCGCTAGCTA –TAACGACTAT Find a string with minimum which contains all these sub-strings

Example – Multiple Sequence Alignment Find a string with minimum which contains all these sub-strings Output AACTAGCGCTAGCTAACGACTAT GCTAGCTAAC AACTAGC AGCGCTAGCTA TAACGACTAT

Example – Sorting By Reversal Given a sequence of integers 1..N Every step you can reverse a continuous sub-subsequence Find the minimum number of steps to sort it

Example – Sorting By Reversal Input – Output – – – –

To know what algorithms are Mathematics –Symbols and notations –Methods Data Structures –Specification of input and output –Internal storage during processing You can recite them. It is science. You can also derive them.

To know how to use algorithms Techniques –Common ways that algorithms are built upon Formulations –How to map the problem domain into entities in algorithms It is art. We have no way to teach you! That’s why you need exercises.

Techniques Recursion –Reduction into sub-problems Divide and Conquer –Reduction into >1 sub-problems –Collect the results Exhaustion –Expand all reductions into sub-problems Greedy –Use only 1 reduction into sub-problem(s) Dynamic Programming –Try all and remember the one

To know why algorithms work Complexity Analysis Proof of correctness Mathematics-oriented Out of our scope, but … To “invent” new algorithms …

HKOI concerns All basics and techniques specified above –Mathematics, Data Structures –Recursion, Exhaustion, Greedy, Algorithms which implement the techniques –Sorting, Searching, DFS, BFS, Prim, Kruskal –Dijkstra, Bellman-Ford, Warshall-Floyd Famous IO models used by algorithms –Tree, Graph –Search Space (Graph Searching) –State Space (Constraint Satisfaction)

Introduction to Algorithms Questions?

HKOI also concerns Modifications to algorithms –To accommodate the situation Multi-state BFS –For speed Branch & Bound –For memory Bit-wise States Other paradigms –Open test data (known input) –Interactive (hidden input)

Complexity An approximation to the runtime and memory requirement of a program. Note that there are –Best-case complexity –Average-case complexity –Worst-case complexity In most cases, we concern runtime only.

Measuring Runtime Definition –An operation –Problem size Consider bubble sort: for i := N - 1 downto 1 do for j := 1 to i do if A[j] > A[j+1] then swap(A[j], A[j+1]); In worst case how many “if” operations? “swap” operations? “for j” operations? “for j” operations? Integer comparisons?

Complexity Give a name to a group of functions with similar growth property, e.g. use O(n 2 ) to mean n 2 + n, 2n 2 – 10n, 10n 2, … Since the constant won’t be too big practically, it is a good indicator of expected runtime. We uses “worst case runtime complexity” (a.k.a. order) extensively to describe runtime of a program

Graph

WA NT SA Q NSW V T

Graph A directed graph G=(V,E), where –V = the set of Node/Vertex –E = the set of Edge/Arc, where E=(v 1,v 2 ) where v 1 and v 2 are in V Extreme: |E| ≤ |V| 2 So we have real algorithms with order: –O(|V| 3 ) –O(|V| + |E|) –O(|V| log |V| + |E|) –O(|E| log(log* |E| – log* |E|/|V|))

Difficulty of Problem Definitions (INCORRECT) –A problem with order being a polynomial is called polynomial-time solvable (P) –A problem whose solution is verified in polynomial time is said to be polynomial-time verifiable (NP) –A problem with no known polynomial-time solution to date is called NP-hard Difficulty of problems are roughly classified as: –Easy: in P (of course all P problems are also in NP) –Hard: in NP but not in P (NP-complete) –Very Hard: not even in NP

Complexity When you have a problem, given input (output) constraints and runtime constraints, you can guess whether an algorithm works or not. But sometimes the stated order of an algorithm depends on some tricky data structures, which we won’t have skills or time to implement!

IOI/NOI Problems Requires Understanding of basic algorithms Innovation on ways to realize the algorithms Technical capability of the realization Remember: Different people care different things in different situations

Finally Information, What Knowledge, How Understanding, Why Induction Deduction