Course Introduction. Algorithm 8/31/2017. COSC 320 Advanced Data Structures and Algorithms. COSC 320 Advanced Data Structures and Algorithms

Similar documents
The Greedy Method. Outline and Reading. Change Money Problem. Greedy Algorithms. Applications of the Greedy Strategy. The Greedy Method Technique

CSCI 104 Sorting Algorithms. Mark Redekopp David Kempe

CSE 326: Data Structures Quicksort Comparison Sorting Bound

Today s Outline. Sorting: The Big Picture. Why Sort? Selection Sort: Idea. Insertion Sort: Idea. Sorting Chapter 7 in Weiss.

Sorting Review. Sorting. Comparison Sorting. CSE 680 Prof. Roger Crawfis. Assumptions

Insertion Sort. Divide and Conquer Sorting. Divide and Conquer. Mergesort. Mergesort Example. Auxiliary Array

Design and Analysis of Algorithms

CSE 326: Data Structures Quicksort Comparison Sorting Bound

Kent State University CS 4/ Design and Analysis of Algorithms. Dept. of Math & Computer Science LECT-16. Dynamic Programming

CS1100 Introduction to Programming

Programming in Fortran 90 : 2017/2018

Greedy Technique - Definition

Sorting: The Big Picture. The steps of QuickSort. QuickSort Example. QuickSort Example. QuickSort Example. Recursive Quicksort

Sequential search. Building Java Programs Chapter 13. Sequential search. Sequential search

Sorting. Sorting. Why Sort? Consistent Ordering

Compiler Design. Spring Register Allocation. Sample Exercises and Solutions. Prof. Pedro C. Diniz

An Optimal Algorithm for Prufer Codes *

Problem Definitions and Evaluation Criteria for Computational Expensive Optimization

Searching & Sorting. Definitions of Search and Sort. Linear Search in C++ Linear Search. Week 11. index to the item, or -1 if not found.

Assignment # 2. Farrukh Jabeen Algorithms 510 Assignment #2 Due Date: June 15, 2009.

Sorting. Sorted Original. index. index

Load Balancing for Hex-Cell Interconnection Network

Problem Set 3 Solutions

More on Sorting: Quick Sort and Heap Sort

Sorting and Algorithm Analysis

Module Management Tool in Software Development Organizations

NUMERICAL SOLVING OPTIMAL CONTROL PROBLEMS BY THE METHOD OF VARIATIONS

A mathematical programming approach to the analysis, design and scheduling of offshore oilfields

Complex Numbers. Now we also saw that if a and b were both positive then ab = a b. For a second let s forget that restriction and do the following.

Priority queues and heaps Professors Clark F. Olson and Carol Zander

$OJRULWKPV. (Feodor F. Dragan) Department of Computer Science Kent State University

Learning the Kernel Parameters in Kernel Minimum Distance Classifier

CMPS 10 Introduction to Computer Science Lecture Notes

CS221: Algorithms and Data Structures. Priority Queues and Heaps. Alan J. Hu (Borrowing slides from Steve Wolfman)

11. APPROXIMATION ALGORITHMS

Dijkstra s Single Source Algorithm. All-Pairs Shortest Paths. Dynamic Programming Solution. Performance. Decision Sequence.

Smoothing Spline ANOVA for variable screening

Hierarchical clustering for gene expression data analysis

Lecture 5: Multilayer Perceptrons

Solving two-person zero-sum game by Matlab

Exercises (Part 4) Introduction to R UCLA/CCPR. John Fox, February 2005

SLAM Summer School 2006 Practical 2: SLAM using Monocular Vision

An Application of the Dulmage-Mendelsohn Decomposition to Sparse Null Space Bases of Full Row Rank Matrices

AADL : about scheduling analysis

ON SOME ENTERTAINING APPLICATIONS OF THE CONCEPT OF SET IN COMPUTER SCIENCE COURSE

U.C. Berkeley CS294: Beyond Worst-Case Analysis Handout 5 Luca Trevisan September 7, 2017

On Some Entertaining Applications of the Concept of Set in Computer Science Course

An Iterative Solution Approach to Process Plant Layout using Mixed Integer Optimisation

Concurrent models of computation for embedded software

Circuit Analysis I (ENGR 2405) Chapter 3 Method of Analysis Nodal(KCL) and Mesh(KVL)

Introduction to Programming. Lecture 13: Container data structures. Container data structures. Topics for this lecture. A basic issue with containers

Intro. Iterators. 1. Access

LECTURE NOTES Duality Theory, Sensitivity Analysis, and Parametric Programming

S1 Note. Basis functions.

Announcements. Supervised Learning

NAG Fortran Library Chapter Introduction. G10 Smoothing in Statistics

6.854 Advanced Algorithms Petar Maymounkov Problem Set 11 (November 23, 2005) With: Benjamin Rossman, Oren Weimann, and Pouya Kheradpour

Simulation: Solving Dynamic Models ABE 5646 Week 11 Chapter 2, Spring 2010

1 Introducton Gven a graph G = (V; E), a non-negatve cost on each edge n E, and a set of vertces Z V, the mnmum Stener problem s to nd a mnmum cost su

Backpropagation: In Search of Performance Parameters

CE 221 Data Structures and Algorithms

Dijkstra s Single Source Algorithm. All-Pairs Shortest Paths. Dynamic Programming Solution. Performance

Machine Learning. Topic 6: Clustering

Range images. Range image registration. Examples of sampling patterns. Range images and range surfaces

O n processors in CRCW PRAM

CHAPTER 10: ALGORITHM DESIGN TECHNIQUES

Support Vector Machines

Comparison of Heuristics for Scheduling Independent Tasks on Heterogeneous Distributed Environments

EECS 730 Introduction to Bioinformatics Sequence Alignment. Luke Huan Electrical Engineering and Computer Science

Parallel Solutions of Indexed Recurrence Equations

Hermite Splines in Lie Groups as Products of Geodesics

Report on On-line Graph Coloring

Brave New World Pseudocode Reference

Solitary and Traveling Wave Solutions to a Model. of Long Range Diffusion Involving Flux with. Stability Analysis

Outline. CHARM: An Efficient Algorithm for Closed Itemset Mining. Introductions. Introductions

Data Representation in Digital Design, a Single Conversion Equation and a Formal Languages Approach

CHAPTER 3 SEQUENTIAL MINIMAL OPTIMIZATION TRAINED SUPPORT VECTOR CLASSIFIER FOR CANCER PREDICTION

Private Information Retrieval (PIR)

Outline. Discriminative classifiers for image recognition. Where in the World? A nearest neighbor recognition example 4/14/2011. CS 376 Lecture 22 1

A New Approach For the Ranking of Fuzzy Sets With Different Heights

Cordial and 3-Equitable Labeling for Some Star Related Graphs

Quicksort. Part 1: Understanding Quicksort

Parallelism for Nested Loops with Non-uniform and Flow Dependences

A Facet Generation Procedure. for solving 0/1 integer programs

Parallel Numerics. 1 Preconditioning & Iterative Solvers (From 2016)

Fast Computation of Shortest Path for Visiting Segments in the Plane

Load-Balanced Anycast Routing

Machine Learning: Algorithms and Applications

Related-Mode Attacks on CTR Encryption Mode

The AVL Balance Condition. CSE 326: Data Structures. AVL Trees. The AVL Tree Data Structure. Is this an AVL Tree? Height of an AVL Tree

Programming Assignment Six. Semester Calendar. 1D Excel Worksheet Arrays. Review VBA Arrays from Excel. Programming Assignment Six May 2, 2017

Classification / Regression Support Vector Machines

Determining the Optimal Bandwidth Based on Multi-criterion Fusion

Dynamic Programming. Example - multi-stage graph. sink. source. Data Structures &Algorithms II

Esc101 Lecture 1 st April, 2008 Generating Permutation

GSLM Operations Research II Fall 13/14

The Shortest Path of Touring Lines given in the Plane


Support Vector Machines

Outline. Self-Organizing Maps (SOM) US Hebbian Learning, Cntd. The learning rule is Hebbian like:

Transcription:

Course Introducton Course Topcs Exams, abs, Proects A quc loo at a few algorthms 1 Advanced Data Structures and Algorthms Descrpton: We are gong to dscuss algorthm complexty analyss, algorthm desgn technques (greedy methods, dvde and conquer, dynamc programmng), and examples of effcent algorthms for varous problems. We wll also dscuss advanced data structure such as Hash Tables, Bnary Search trees, and ed-blac trees. We wll also dscuss the noton of NP-completeness and NP-complete problems. Prerequstes: Computer Scence II (COSC 220) and Dscrete Mathematcs (MATH 210), both completed wth a grade of C or better. Prmary eference: Introducton to Algorthms 3 rd edton by Thomas H. Cormen, Charles E. eserson, onald. vest and Clfford Sten, MIT Press 2 Advanced Data Structures and Algorthms Topcs nclude: Mathematcal Foundaton for Analyss of Algorthms Set Notaton, Asymptotc Notatons (Bg-, Bg-O and Bg-, lttle-o, lttle- notatons) Best-Case, Worst-Case, Average- Case unnng Tmes Sortng Algorthms and Analyss Inserton Sort, Selecton Sort, Bubble Sort, Shell Sort, Merge Sort, Heap Sort, Quc Sort, near tme Sortng Algorthms: adx Sort, Bucet Sort, Countng Sort and analyss of these algorthms. Selecton Problems Maxmum, Mnmum, MnMax, General Selecton Problems Advanced Data Structures and Algorthms Topcs nclude: Advanced Data Structures Bnary Search Trees, varous Balanced Bnary Search Trees, ed-blac trees, Heaps and Prorty Queues, Dsont Set Data Structures, Hash Tables and algorthms used for these Data Structures. Graph Algorthms Graph representatons, Breadth-Frst Search, Depth-Frst Search, Mnmum Spannng Tree, Shortest Path, Maxmum Flow, and analyses of these algorthms. NP-Completeness Polynomal tme, Polynomal tme verfcaton, NPcompleteness and reducblty 3 4 Advanced Data Structures and Algorthms Exams: There wll be three exams -- two mdterms and a fnal. Once the dates are set, they wll be posted on the course web page. There wll be no mae-ups or reschedulng of exams (except n emergency cases wth evdence). abs & Proects: There wll be a seres of labs and/or proects that consst of mplementng varous algorthms and data structures or learnng new language features. Each student s requred to attend a lab sesson each wee. It s mportant to arrve on tme for each lab sesson. Each student needs to read any assgned pre-lab readngs before startng each lab sesson. Some of the labs can be completed n the lab sesson, but others wll be more dffcult and tme consumng and wll need to be completed outsde of class. Algorthm What s an algorthm? An algorthm s any well-defned computatonal procedure that taes some value, or set of values, as nput and produces some value, or set of values, as output. Input Algorthm Output Fall 2017 5 6 1

Algorthm Algorthm An algorthm s a sequence of computatonal steps that transform the nput nto the output. An algorthm s a tool for solvng a well-specfed computatonal problem. Ex) sortng problem A sequence of n numbers <a 1, a 2, a 3, a n > Sortng Algorthm Permutaton <a 1, a 2, a 3, a n > of nput sequence such that a 1 a 2 a 3 a n What s a correct algorthm for solvng a problem? An algorthm s sad to be correct f t halts wth the correct output for every possble nput. What crtera are used to determne whch algorthm s better? Measure of effcency s speed How long an algorthm taes to produce output. How do we evaluate whch algorthm s better? By analyzng algorthms mathematcally 7 8 Greedy Method follows the problem solvng heurstc of mang the locally optmal choce at each stage n the hope of fndng a global optmum. Dvde and Conquer wors by recursvely breang down a problem nto two or more sub-problems of the same (or related) type, untl these sub-problems become smple enough to be solved drectly. Dynamc Programmng solves complex problems by breang them down nto smpler sub-problems. It s applcable to problems exhbtng the propertes of overlappng sub-problems whch are only slghtly smaller (Greedy: Con Change) Problem Mae change for a gven amount usng the smallest possble number of cons. The avalable cons are: dollars (100 cents) quarters (25 cents) dmes (10 cents) ncels (5 cents) pennes (1 cent) 9 10 (Greedy: Con Change) (Greedy: Con Change) Greedy strategy Sum = 0 epeatedly choose the largest con such that Sum + Total change amount Greedy methods do not wor n all cases!! For example: Con set = 8, 5, 1; Change = 10. Greedy Soluton = 8, 1, 1 Optmal Soluton (.e., fewest # of cons) = 5, 5 11 12 2

(Dynamc Programmng: Fbonacc Sequence) (Dynamc Programmng: Fbonacc Sequence) nt fb(nt n) f n == 0 or n == 1 return 1; else return fb(n-1) + fb(n-2); Notce that f we call, say, fb(5), we produce a call tree that calls the functon on the same value many dfferent tmes. In partcular, fb(2) s calculated three tmes from scratch. In larger examples, even more values of fb,.e., subproblems, are recalculated, resultng n an exponental tme algorthm. 1. fb(5) 2. fb(4) + fb(3) 3. (fb(3) + fb(2)) + (fb(2) + fb(1)) 4. ((fb(2) + fb(1)) + (fb(1) + fb(0))) + ((fb(1) + fb(0)) + fb(1)) 5. (((fb(1) + fb(0)) + fb(1)) + (fb(1) + fb(0))) + ((fb(1) + fb(0)) + fb(1)) We can mprove recurrence verson of Fbonacc sequence by usng dynamc programmng dea. Now, suppose we have a smple map obect, m, whch maps each value of fb that has already been calculated to ts result. The resultng functon requres only O(n) tme nstead of exponental tme (but requres O(n) space): map M (ey, value) M(0) = 1; M(1) = 1; nt fb(nt n) f map M does not contan ey n else return M(n)= fb(n-1)+ fb(n-2); return M(n) (Dvde & Conquer: Merge Sort) Merge Sort The merge sort algorthm s representatve of the dvde-and-conquer paradgm. Dvde: Dvde the n-element sequence to be sorted nto two subsequences of n/2 elements each. Conquer: Sort each subsequence recursvely usng merge sort. Combne: Merge the two sorted subsequences to produce the sorted result. (Dvde & Conquer: Merge Sort) f (p < r) Frst element ndex of array A ast element ndex of array A 15 16 (Dvde & Conquer: Merge Sort) (Dvde & Conquer: Merge Sort) MergeSort(A, 0, 7) A MergeSort(A, 0, 3) MergeSort(A, 4, 7) 17 18 3

(Dvde & Conquer: Merge Sort) (Dvde & Conquer: Merge Sort) MergeSort(A, 0, 1) MergeSort(A, 2, 3) MergeSort(A, 4, 5) MergeSort(A, 6, 7) 19 20 (Dvde & Conquer: Merge Sort) (Dvde & Conquer: Merge Sort) 0 1 2 3 3 4 5 6 2 3 4 6 0 1 3 5 Merge Merge Merge 4 6 2 3 0 5 1 3 Merge Merge Merge Merge Merge(A, p, q, r) n1 = q p + 1; n2 = r q; for = 1 to n1 [] = A[p + 1]; // s a local array for = 1 to n2 [] = A[q + ]; // s a local array [n1 + 1] = ; [n2 + 1] = ; = = 1; for = p to r f [] [] then A[] = []; = + 1; else A[] = []; = +1; // end for-loop // end of Merge functon 21 22 p q q+1 r = p 0 2 2 3 5 0 1 3 4 6 0 2 2 3 5 0 1 3 4 6 0 2 2 3 5 0 1 3 4 6 23 24 4

0 2 2 3 5 0 1 3 4 6 0 0 2 3 5 0 1 3 4 6 0 2 2 3 5 0 1 3 4 6 0 2 2 3 5 0 1 3 4 6 25 26 0 0 1 3 5 0 1 3 4 6 0 0 1 2 5 0 1 3 4 6 0 2 2 3 5 0 1 3 4 6 0 2 2 3 5 0 1 3 4 6 27 28 0 0 1 2 2 0 1 3 4 6 0 0 1 2 2 3 1 3 4 6 0 2 2 3 5 0 1 3 4 6 0 2 2 3 5 0 1 3 4 6 29 30 5

0 0 1 2 2 3 3 3 4 6 0 0 1 2 2 3 3 4 4 6 0 2 2 3 5 0 1 3 4 6 0 2 2 3 5 0 1 3 4 6 31 32 = r 0 0 1 2 2 3 3 4 5 6 0 0 1 2 2 3 3 4 5 6 0 2 2 3 5 0 1 3 4 6 0 2 2 3 5 0 1 3 4 6 33 34 Merge Sort Performance Snce Merge sort dvdes a lst nto two balanced lsts, the runnng tme s the same all of the tme (.e., Best case = Worst case). (1), T ( n) 2T ( n ) ( n), 2 n 1 n 1 35 6