Introduction to HKOI. Self Introduction Ice Breaking Game.

Slides:



Advertisements
Similar presentations
Growth-rate Functions
Advertisements

MATH 224 – Discrete Mathematics
Algorithms Recurrences. Definition – a recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs Example.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Midterm Review Fri. Oct 26.
Wednesday, 11/25/02, Slide #1 CS 106 Intro to CS 1 Wednesday, 11/25/02  QUESTIONS??  Today:  More on sorting. Advanced sorting algorithms.  Complexity:
Greedy Algorithms Like dynamic programming algorithms, greedy algorithms are usually designed to solve optimization problems Unlike dynamic programming.
Data Structures, Spring 2004 © L. Joskowicz 1 DAST – Final Lecture Summary and overview What we have learned. Why it is important. What next.
The Complexity of Algorithms and the Lower Bounds of Problems
DAST, Spring © L. Joskowicz 1 Data Structures – LECTURE 1 Introduction Motivation: algorithms and abstract data types Easy problems, hard problems.
Chapter 1 Introduction Definition of Algorithm An algorithm is a finite sequence of precise instructions for performing a computation or for solving.
February 17, 2015Applied Discrete Mathematics Week 3: Algorithms 1 Double Summations Table 2 in 4 th Edition: Section th Edition: Section th.
COMP s1 Computing 2 Complexity
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.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Spring, 2002 Lecture 1 Introduction/Overview Text: Chapters 1, 2 Thurs.
1 Complexity Lecture Ref. Handout p
CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.
An Introduction to Programming Concepts and OI-programming …from abstract theory to dirty tricks…
Week 2 CS 361: Advanced Data Structures and Algorithms
Nyhoff, ADTs, Data Structures and Problem Solving with C++, Second Edition, © 2005 Pearson Education, Inc. All rights reserved ADT Implementation:
Unit III : Introduction To Data Structures and Analysis Of Algorithm 10/8/ Objective : 1.To understand primitive storage structures and types 2.To.
Chapter 12 Recursion, Complexity, and Searching and Sorting
Analysis of Algorithms
26 Sep 2014Lecture 3 1. Last lecture: Experimental observation & prediction Cost models: Counting the number of executions of Every single kind of command.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 19: Searching and Sorting.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
OI-style programming Gary Wong For any questions, please ask via MSN:
Data Structures and Algorithms Introduction to Algorithms M. B. Fayek CUFE 2006.
December 4, Algorithms and Data Structures Lecture XV Simonas Šaltenis Aalborg University
Chapter 24: Single-Source Shortest Paths Given: A single source vertex in a weighted, directed graph. Want to compute a shortest path for each possible.
Data Structure Introduction.
CS 61B Data Structures and Programming Methodology July 21, 2008 David Sun.
Algorithm Analysis CS 400/600 – Data Structures. Algorithm Analysis2 Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely.
Priority Queues and Heaps. October 2004John Edgar2  A queue should implement at least the first two of these operations:  insert – insert item at the.
CS223 Advanced Data Structures and Algorithms 1 Review for Final Neil Tang 04/27/2010.
3.3 Complexity of Algorithms
HKOI 2005 Training Introduction to Algorithms Alan, Tam Siu Lung.
1 BIM304: Algorithm Design Time: Friday 9-12am Location: B4 Instructor: Cuneyt Akinlar Grading –2 Midterms – 20% and 30% respectively –Final – 30% –Projects.
Introduction to HKOI Gary Wong. Ice Breaking and bond forming…
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 23 Algorithm Efficiency.
Introduction to HKOI 13 January Benefits of Joining HKOI  Improve your problem solving skills  Prizes (you already have some)  Chances to represent.
C++ How to Program, 7/e © by Pearson Education, Inc. All Rights Reserved.
Searching Topics Sequential Search Binary Search.
CS6045: Advanced Algorithms Sorting Algorithms. Heap Data Structure A heap (nearly complete binary tree) can be stored as an array A –Root of tree is.
Priority Queues, Heaps, and Heapsort CSE 2320 – Algorithms and Data Structures Vassilis Athitsos University of Texas at Arlington 1.
Chapter 9: Sorting1 Sorting & Searching Ch. # 9. Chapter 9: Sorting2 Chapter Outline  What is sorting and complexity of sorting  Different types of.
CSCE 411 Design and Analysis of Algorithms Set 9: More Graph Algorithms Prof. Jennifer Welch Spring 2012 CSCE 411, Spring 2012: Set 9 1.
Sorting & Searching Geletaw S (MSC, MCITP). Objectives At the end of this session the students should be able to: – Design and implement the following.
DATA STRUCTURES Prepared by, K.ABINAYA L/IT. Aim: To present the concepts of arrays, structures, stack, queue, linked list, graphs, trees and storage.
Data Structures and Algorithm Analysis Graph Algorithms Lecturer: Jing Liu Homepage:
Complexity of Algorithms Fundamental Data Structures and Algorithms Ananda Guna January 13, 2005.
Ch03-Algorithms 1. Algorithms What is an algorithm? An algorithm is a finite set of precise instructions for performing a computation or for solving a.
Chapter 3 Chapter Summary  Algorithms o Example Algorithms searching for an element in a list sorting a list so its elements are in some prescribed.
Introduction to Algorithm Complexity Bit Sum Problem.
Algorithm homework help For More Detail help.aspx - Phone:-
Introduction to Algorithms
CS 583 Fall 2006 Analysis of Algorithms
Enough Mathematical Appetizers!
CS302 Data Structures Fall 2012.
CS 3343: Analysis of Algorithms
Computation.
Introduction to Algorithms
CS 3343: Analysis of Algorithms
Definition In simple terms, an algorithm is a series of instructions to solve a problem (complete a task) We focus on Deterministic Algorithms Under the.
The Complexity of Algorithms and the Lower Bounds of Problems
Foundations II: Data Structures and Algorithms
CS 3343: Analysis of Algorithms
Objective of This Course
Applied Discrete Mathematics Week 6: Computation
Enough Mathematical Appetizers!
Presentation transcript:

Introduction to HKOI

Self Introduction

Ice Breaking Game

Level 1 Level 1 Form a big circle Form a big circle The person holding the deck of cards will start the game, by introducing himself, and then passes the deck of cards to his left. The person holding the deck of cards will start the game, by introducing himself, and then passes the deck of cards to his left. In each preceding turn, the person holding the deck of cards will repeat what the previous person has said, and then introduces himself. After that, he will passes the deck to his left. In each preceding turn, the person holding the deck of cards will repeat what the previous person has said, and then introduces himself. After that, he will passes the deck to his left. The game ends when the deck of cards return to the first person. The game ends when the deck of cards return to the first person.

Ice Breaking Game Level 2 Level 2 Form a big circle Form a big circle The person holding the deck of cards will start the game, by introducing himself and drawing a card from the deck. After that, he will pass the deck of cards to the k th person on his left, where k is the number written on the card he draw. The person holding the deck of cards will start the game, by introducing himself and drawing a card from the deck. After that, he will pass the deck of cards to the k th person on his left, where k is the number written on the card he draw. In each preceding turn, the person holding the deck of cards will repeat what the previous person has said, and then introduces himself. After that, he will draw a card from the deck and pass the deck of cards to the k th person on his left, where k is the number written on the card he draw. In each preceding turn, the person holding the deck of cards will repeat what the previous person has said, and then introduces himself. After that, he will draw a card from the deck and pass the deck of cards to the k th person on his left, where k is the number written on the card he draw. The game ends when the deck runs out of cards. The game ends when the deck runs out of cards.

Problems Just like in Final Events Just like in Final Events Usually starts with a story or a situation in daily life. Usually starts with a story or a situation in daily life. e.g. A group of people is playing an ice-breaking game e.g. A group of people is playing an ice-breaking game Specifies a set of well-defined inputs, and the corresponding outputs Specifies a set of well-defined inputs, and the corresponding outputs What can be the input and output of the ice-breaking game we played? What can be the input and output of the ice-breaking game we played? Sometimes, there may be more than one correct output, and the problem only requires you to output any one of the them. Sometimes, there may be more than one correct output, and the problem only requires you to output any one of the them. Be careful of the format of the input and output! Be careful of the format of the input and output! Example: sorting Example: sorting

Algorithms “ Informally, an algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output. An algorithm is thus a sequence of computational steps that transform the input into the output. ” [CLRS] “ Informally, an algorithm is any well-defined computational procedure that takes some value, or set of values, as input and produces some value, or set of values, as output. An algorithm is thus a sequence of computational steps that transform the input into the output. ” [CLRS] An algorithm ( 算法 ) is a method to solve a problem. An algorithm ( 算法 ) is a method to solve a problem. There may be more than one algorithms corresponding to a problem. There may be more than one algorithms corresponding to a problem. Take sorting as an example. Bubble sort and insertion sort are algorithms that solves the problem. Take sorting as an example. Bubble sort and insertion sort are algorithms that solves the problem. We usually regard algorithms as language independent. We usually regard algorithms as language independent. An algorithm, by definition, must eventually terminates. An algorithm, by definition, must eventually terminates. Many important algorithms are named after Computer Scientists. Many important algorithms are named after Computer Scientists.

Algorithms Tree-Search algorithms Tree-Search algorithms Depth-First Search Depth-First Search Breath-First Search Breath-First Search Graph algorithms Graph algorithms Dijkstra ’ s Dijkstra ’ s Floyd-Warshall Floyd-Warshall Bellman-Ford Bellman-Ford Prim ’ s Prim ’ s Kruskal ’ s Kruskal ’ s Convex Hull algorithm Convex Hull algorithm Graham ’ s scan Graham ’ s scan WA NT SA Q NSW V T

Data Structures Data structures ( 數據結構 ) are how we organize and store the input data, or intermediate results of computation Data structures ( 數據結構 ) are how we organize and store the input data, or intermediate results of computation Helps to speed up algorithms Helps to speed up algorithms Different data structures have different properties Different data structures have different properties different types of data different types of data different types of operations different types of operations Examples Examples Array Array Stack Stack Queue Queue Heap Heap Binary Search Tree Binary Search Tree

Complexity We want to know how well an algorithm “ scales ” (i.e. when there is a large input). We want to know how well an algorithm “ scales ” (i.e. when there is a large input). Usually, minor improvements are not critical in competitions. Usually, minor improvements are not critical in competitions. A reasonable implementation can pass. A reasonable implementation can pass. So, we want to hide the lower order terms. So, we want to hide the lower order terms. We do not know the exact time each operation takes. We do not know the exact time each operation takes. So, we want to measure the time by counting the number of basic operations. So, we want to measure the time by counting the number of basic operations.

Complexity

Complexity Big-O notation Big-O notation Definition Definition We say that f(x) is in O(g(x)) if and only if there exist numbers x 0 and M such that |f(x)| ≤ M |g(x)| for x > x 0

Complexity Bubble sort Bubble sort For i := 1 to n do For j := 2 to i do if a[j] > a[j-1] then swap(a[j], a[j-1]); For i := 1 to n do For j := 2 to i do if a[j] > a[j-1] then swap(a[j], a[j-1]); Worst case number of swaps = n(n-1)/2 Worst case number of swaps = n(n-1)/2 Time Complexity = O(n 2 ) Time Complexity = O(n 2 ) Total space needed = size of array + space of variables Total space needed = size of array + space of variables Space Complexity = 32*n +32*3 = O(n) +O(1) = O(n) Space Complexity = 32*n +32*3 = O(n) +O(1) = O(n)

Complexity Binary search Binary search While a<=b do While a<=b dom=(a+b)/2 If a[m]=key, Then return m If a[m]<key, Then a=m+1 If a[m]>key, Then b=m-1 Worst case number of iterations = lg n Worst case number of iterations = lg n Time Complexity = O(log n) Time Complexity = O(log n) Total space needed = size of array + space of variables Total space needed = size of array + space of variables Space Complexity = O(n) Space Complexity = O(n)

Complexity Usually, the time complexity of the algorithm gives us a rough estimation of the actual run time. Usually, the time complexity of the algorithm gives us a rough estimation of the actual run time. O(n) for n ~ O(n) for n ~ O(n log n) for n ~ 5x10 5 O(n log n) for n ~ 5x10 5 O(n 2 ) for n ~ O(n 2 ) for n ~ O(n 3 ) for n ~ 100~1000 O(n 3 ) for n ~ 100~1000 O(n 4 ) for n ~ O(n 4 ) for n ~ O(k n ) (k>1) or O(n!) for very small n, usually 1) or O(n!) for very small n, usually < 20 Keep in mind Keep in mind The constant hidden by Big-O notation (including the algorithm and the details implementation) The constant hidden by Big-O notation (including the algorithm and the details implementation) Computers vary in speeds, so the time needed will be different. In fact, computers are getting faster these days. Computers vary in speeds, so the time needed will be different. In fact, computers are getting faster these days. Read the instructions carefully for the time limit. Read the instructions carefully for the time limit. Test the program/computer before making assumptions! Test the program/computer before making assumptions!

Training Session Topics are divided into two categories, such that students may master the necessary skills after two years of training Topics are divided into two categories, such that students may master the necessary skills after two years of training Intermediate: designed for students who have never entered training team in the past Intermediate: designed for students who have never entered training team in the past Advanced: designed for students who are familiar with intermediate topics Advanced: designed for students who are familiar with intermediate topics All topics are open to all trainees. All topics are open to all trainees. We strongly recommend that students make sure they have the necessary background knowledge before they attend a training session. We strongly recommend that students make sure they have the necessary background knowledge before they attend a training session.

Training Session On Saturdays (including some public holidays) On Saturdays (including some public holidays) Venue Venue HW312(Intermediate) and HW311(Advanced), Haking Wong Building, The University of Hong Kong HW312(Intermediate) and HW311(Advanced), Haking Wong Building, The University of Hong Kong AM Session AM Session regular training topics regular training topics 10:00am – 1:00pm 10:00am – 1:00pm Lunch Lunch Questions and discussions Questions and discussions Making friends Making friends PM Session PM Session 2:00pm – 5:00pm 2:00pm – 5:00pm Detailed schedule is available in the official website ( Detailed schedule is available in the official website ( Training notes will be uploaded after each training session. Training notes will be uploaded after each training session.

Training Topics Algorithms and Data Structures Algorithms and Data Structures Linux Linux Free, popular and powerful Free, popular and powerful Competition environment Competition environment C++ C++ Advantage of Stardard Template Library (STL) Advantage of Stardard Template Library (STL)

Training References Books Books “ Introduction to Algorithms ” by Cormen, Leiserson, Rivest, Stein [CLRS] “ Introduction to Algorithms ” by Cormen, Leiserson, Rivest, Stein [CLRS] Heapsort, Quicksort, Sorting in Linear Time, Elementary Data Structures, Binary Search Trees, Dynamic Programming, Greedy Algorithms, Data Structures for Disjoint Sets, Elementary Graph Algorithms, Minimum Spanning Trees, Single-Source Shortest Path, All-Pairs Shortest Path Heapsort, Quicksort, Sorting in Linear Time, Elementary Data Structures, Binary Search Trees, Dynamic Programming, Greedy Algorithms, Data Structures for Disjoint Sets, Elementary Graph Algorithms, Minimum Spanning Trees, Single-Source Shortest Path, All-Pairs Shortest Path Online Online Wikipedia ( Wikipedia (

Online Judge HKOI Judge (HKOJ) HKOI Judge (HKOJ) After each training, some problems are open for practice. After each training, some problems are open for practice. Update your personal information. Update your personal information. Take attendance on your own every training. Take attendance on your own every training. Rank, score and attendance are for reference only. Rank, score and attendance are for reference only.

Team Formation Test 29 May May 2010 Trainees with outstanding performance can represent Hong Kong in international and national competitions Trainees with outstanding performance can represent Hong Kong in international and national competitions The delegation selection algorithm is based on the score of the Team Formation Test (TFT) The delegation selection algorithm is based on the score of the Team Formation Test (TFT)

External Competitions International Olympiad of Informatics (IOI) International Olympiad of Informatics (IOI) August Canada August Canada National Olympiad of Informatics (NOI) National Olympiad of Informatics (NOI) 全國信息學奧林匹克競賽 全國信息學奧林匹克競賽