+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,

Slides:



Advertisements
Similar presentations
Divide-and-Conquer 7 2  9 4   2   4   7
Advertisements

Divide and Conquer (Merge Sort)
CS16: Data Structures & Algorithms | Spring 2014 Midterm Review 3/16/
A simple example finding the maximum of a set S of n numbers.
Comp 122, Spring 2004 Divide and Conquer (Merge Sort)
1 Divide & Conquer Algorithms. 2 Recursion Review A function that calls itself either directly or indirectly through another function Recursive solutions.
September 12, Algorithms and Data Structures Lecture III Simonas Šaltenis Nykredit Center for Database Research Aalborg University
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.
11 Computer Algorithms Lecture 6 Recurrence Ch. 4 (till Master Theorem) Some of these slides are courtesy of D. Plaisted et al, UNC and M. Nicolescu, UNR.
Algorithms Recurrences. Definition – a recurrence is an equation or inequality that describes a function in terms of its value on smaller inputs Example.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
CS3381 Des & Anal of Alg ( SemA) City Univ of HK / Dept of CS / Helena Wong 4. Recurrences - 1 Recurrences.
Midterm Exam Two Tuesday, November 25 st In class cumulative.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (3) Recurrence Relation 11/11 ~ 11/14/2008 Yang Song.
Updates HW#1 has been delayed until next MONDAY. There were two errors in the assignment Merge sort runs in Θ(n log n). Insertion sort runs in Θ(n2).
Recurrences Part 3. Recursive Algorithms Recurrences are useful for analyzing recursive algorithms Recurrence – an equation or inequality that describes.
Recurrences The expression: is a recurrence. –Recurrence: an equation that describes a function in terms of its value on smaller functions Analysis of.
Recurrence Relations Connection to recursive algorithms Techniques for solving them.
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
Recurrences The expression: is a recurrence. –Recurrence: an equation that describes a function in terms of its value on smaller functions BIL741: Advanced.
Divide-and-Conquer 7 2  9 4   2   4   7
Analysis of Algorithms
Analyzing Recursive Algorithms A recursive algorithm can often be described by a recurrence equation that describes the overall runtime on a problem of.
10/13/20151 CS 3343: Analysis of Algorithms Lecture 9: Review for midterm 1 Analysis of quick sort.
Divide-and-Conquer1 7 2  9 4   2  2 79  4   72  29  94  4.
Project 2 due … Project 2 due … Project 2 Project 2.
DR. NAVEED AHMAD DEPARTMENT OF COMPUTER SCIENCE UNIVERSITY OF PESHAWAR LECTURE-5 Advance Algorithm Analysis.
Lecture 2 Sorting. Sorting Problem Insertion Sort, Merge Sort e.g.,
+ Review CS302 Spring 2013 David Kauchak. + Admin Final posted on the course web page on Monday due Sunday at 11:59pm time-boxed (3-4 hours) You may use:
CompSci 102 Discrete Math for Computer Science April 17, 2012 Prof. Rodger.
CS 361 – Chapters 8-9 Sorting algorithms –Selection, insertion, bubble, “swap” –Merge, quick, stooge –Counting, bucket, radix How to select the n-th largest/smallest.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 3.
Recurrences David Kauchak cs161 Summer Administrative Algorithms graded on efficiency! Be specific about the run times (e.g. log bases) Reminder:
+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,
Divide-and-Conquer UNC Chapel HillZ. Guo. Divide-and-Conquer It’s a technique instead of an algorithm Recursive in structure – Divide the problem into.
Foundations II: Data Structures and Algorithms
Solving Recurrences with the Substitution Method.
1Computer Sciences. 2 GROWTH OF FUNCTIONS 3.2 STANDARD NOTATIONS AND COMMON FUNCTIONS.
1Computer Sciences Department. Objectives Recurrences.  Substitution Method,  Recursion-tree method,  Master method.
Mergeable Heaps David Kauchak cs302 Spring Admin Homework 7?
Recurrences (in color) It continues…. Recurrences When an algorithm calls itself recursively, its running time is described by a recurrence. When an algorithm.
Divide and Conquer Faculty Name: Ruhi Fatima Topics Covered Divide and Conquer Matrix multiplication Recurrence.
CSC317 1 So far so good, but can we do better? Yes, cheaper by halves... orkbook/cheaperbyhalf.html.
Big O David Kauchak cs302 Spring Administrative Assignment 1: how’d it go? Assignment 2: out soon… Lab code.
Equal costs at all levels
Analysis of Algorithms CS 477/677
Introduction to Algorithms: Recurrences
CS 3343: Analysis of Algorithms
Divide-and-Conquer 6/30/2018 9:16 AM
Unit 1. Sorting and Divide and Conquer
CS 3343: Analysis of Algorithms
David Kauchak CS52 – Spring 2015
Divide and Conquer.
CS 3343: Analysis of Algorithms
Chapter 2: Getting Started
CS 3343: Analysis of Algorithms
Algorithms and Data Structures Lecture III
Divide-and-Conquer 7 2  9 4   2   4   7
CSE 373 Data Structures and Algorithms
Divide and Conquer (Merge Sort)
CS 3343: Analysis of Algorithms
Divide-and-Conquer 7 2  9 4   2   4   7
Trevor Brown CS 341: Algorithms Trevor Brown
Divide & Conquer Algorithms
David Kauchak cs161 Summer 2009
Divide-and-Conquer 7 2  9 4   2   4   7
Presentation transcript:

+ David Kauchak cs312 Review

+ Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem, move on and come back Must take it by Friday at 6pm You may use: your book your notes the class notes ONLY these things Do NOT discuss it with anyone until after Friday at 6pm

+ Midterm General what is an algorithm algorithm properties pseudocode proving correctness loop invariants run time analysis memory analysis

+ Midterm Big O proving bounds ranking/ordering of functions Amortized analysis Recurrences solving recurrences substitution method recursion-tree master method

+ Midterm Sorting insertion sort merge sort merge function quick sort partition function bubble sort heap sort

+ Midterm Divide and conquer divide up the data (often in half) recurse possibly do some work to combine the answer Calculating order statistics/medians Basic data structures set operations array linked lists stacks queues

+ Midterm Heaps binary heaps binomial heaps Search trees BSTs B-trees Disjoint sets (very briefly)

+ Midterm Other things to know: run-times (you shouldn’t have to look all of them up, though I don’t expect you to memorize them either) when to use an algorithm proof techniques look again an proofs by induction Make sure to follow the explicit form we covered in class proof by contradiction

+ Proofs - prove by induction: 1+x^n >= 1+nx for all nonnegative integers n and all x >= − base case -- inductive case --- inductive hypothesis --- inductive step to prove --- proof of inductive step

+ Proofs - prove by contradiction: For all integers n, if n2 is odd, then n is odd.

+ Substitution method Master method:

+ Substitution method Assume T(k) = O(k 2 ) for all k < n Show that T(n) = O(n 2 ) Given that T(n/4) = O((n/4) 2 ), then T(n/4) ≤ c(n/4) 2

+ To prove that Show that T(n) = O(n 2 ) we need to identify the appropriate constants: if i.e. some constant c such that T(n) ≤ cn 2

+ Changing variables Guesses? We can do a variable change: let m = log 2 n (or n = 2 m ) Now, let S(m)=T(2 m )

+ Changing variables Guess? substituting m=log n