Announcements Quiz 4 will be on next Friday (4/3). It will cover materials from Chapter 4. Check your grades on WebCT and notify me promptly if you see.

Slides:



Advertisements
Similar presentations
Back to Sorting – More efficient sorting algorithms.
Advertisements

CS 1031 Recursion (With applications to Searching and Sorting) Definition of a Recursion Simple Examples of Recursion Conditions for Recursion to Work.
Lectures on Recursive Algorithms1 COMP 523: Advanced Algorithmic Techniques Lecturer: Dariusz Kowalski.
Divide and Conquer Chapter 6. Divide and Conquer Paradigm Divide the problem into sub-problems of smaller sizes Conquer by recursively doing the same.
Discrete Structures & Algorithms More on Methods of Proof / Mathematical Induction EECE 320 — UBC.
MergeSort (Example) - 1. MergeSort (Example) - 2.
CSE115/ENGR160 Discrete Mathematics 04/05/11 Ming-Hsuan Yang UC Merced 1.
Algorithm Design Techniques: Induction Chapter 5 (Except Section 5.6)
CS 280 Data Structures Professor John Peterson. Test #1 We’ll do a test next week on Wednesday. It will take the entire period. You can have 1 page of.
CSSE221: Software Dev. Honors Day 23 Announcements: Announcements: Pass in yesterday’s capsule quiz Pass in yesterday’s capsule quiz Homework 7 electronic.
Administrative Issues ICS 151 Fall 2007 Instructor: Eli Bozorgzadeh.
Section Section Summary Recursive Algorithms Proving Recursive Algorithms Correct Recursion and Iteration (not yet included in overheads) Merge.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Instructor: Paul Beame TA: Gidon Shavit.
MergeSort Source: Gibbs & Tamassia. 2 MergeSort MergeSort is a divide and conquer method of sorting.
Induction and recursion
COMP 151: Computer Programming II Spring Course Topics Review of Java and basics of software engineering (3 classes. Chapters 1 and 2) Recursion.
HOW TO SOLVE IT? Algorithms. An Algorithm An algorithm is any well-defined (computational) procedure that takes some value, or set of values, as input.
Dr. Philip Cannata 1 Wrap-Up. Dr. Philip Cannata 2 Final Review Final Questions Distribution Review Midterm, All Homework and All Quizzes Review IP Addressing.
Administrative Issues ICS 151 Winter 2010 Instructor: Eli Bozorgzadeh.
4.4 Recursive Algorithms A recursive algorithm is one which calls itself to solve “smaller” versions of an input problem. How it works: – The current status.
8/19/2003CS 303 – Administrivia Lecture 0 1 Administrivia Labs Homework Grades Exams Quiz.
CS 61B Data Structures and Programming Methodology July 28, 2008 David Sun.
CS-2851 Dr. Mark L. Hornick 1 CS-2852 Data Structures Dr. Mark L. Hornick Office: L341 Phone: web: people.msoe.edu/hornick/
Divide and Conquer Applications Sanghyun Park Fall 2002 CSE, POSTECH.
Searching and Sorting Recursion, Merge-sort, Divide & Conquer, Bucket sort, Radix sort Lecture 5.
Big Oh Notation Greek letter Omicron (Ο) is used to denote the limit of asymptotic growth of an algorithm If algorithm processing time grows linearly with.
Lecture 6 Complex Sorting 1. Announcements Homework 3 due Monday No participation this week Test is on Thursday Part of Wednesday will be review I will.
Announcements: Project 5 Everything we have been learning thus far will enable us to solve interesting problems Project 5 will focus on applying the skills.
Introduction to Statistics I MATH 1131, Summer I 2008, Department of Math. & Stat., York University.
7.3 Divide-and-Conquer Algorithms and Recurrence Relations If f(n) represents the number of operations required to solve the problem of size n, it follow.
Week 10, Day Three. Homework Check Distributive Property Worksheet Distributive Property and Factoring Answers.pdf.
Recursive Algorithm (4.4) An algorithm is called recursive if it solves a problem by reducing it to an instance of the same problem with smaller input.
CSCI-256 Data Structures & Algorithm Analysis Lecture Note: Some slides by Kevin Wayne. Copyright © 2005 Pearson-Addison Wesley. All rights reserved. 11.
In The Name of God. Parallel processing Course Evaluation  Final Exam is closed book( 14 Scores)  Research and Presentation, Quizzes (5 Scores)  No.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
DEVRY FIN 515 Entire Course NEW Check this A+ tutorial guideline at For more classes.
Recursive Algorithms Section 5.4.
Welcome to CC8/ALG 1 As you come in, please grab a half sheet of paper from the front desk and begin filling it out.
CS 162 Intro to Programming II
CS2210:0001Discrete Structures Induction and Recursion
Quick overview of your schedule Spring-2017 SPAU 3343
Divide and Conquer.
CSCE350 Algorithms and Data Structure
Final Grade Averages Weighted Averages.
MergeSort Source: Gibbs & Tamassia.
(2,4) Trees 11/15/2018 9:25 AM Sorting Lower Bound Sorting Lower Bound.
Welcome to Geometry As you come in, please grab a half sheet of paper from the front desk and begin filling it out.
11/20/2018 Math is awesome!.
11/24/2018 Math is awesome!.
Algebra Review: Solving Equations
MSIS 655 Advanced Business Applications Programming
Physics 101: Lecture 29 Exam Results & Review
Lab 9 & 10: Drill 2 and Homework 4
Best Practices for Teaching Online
Administrative Issues
(2,4) Trees 2/28/2019 3:21 AM Sorting Lower Bound Sorting Lower Bound.
Trevor Brown CS 341: Algorithms Trevor Brown
Administrative Issues
Lecture 15, Winter 2019 Closest Pair, Multiplication
Application: Efficiency of Algorithms II
Randomized Algorithms CS648
Administrative Issues
Application: Efficiency of Algorithms II
Merge Sort Procedure MergeSort (L = a1, a2, , an) if (n > 1)
CSE 332: Parallel Algorithms
Core Assessments Core #1: This Friday (5/4) Core #2: Tuesday, 5/8.
Induction and recursion
CMPT 238 Data Structures Instructor: Tina Tian.
Presentation transcript:

Announcements Quiz 4 will be on next Friday (4/3). It will cover materials from Chapter 4. Check your grades on WebCT and notify me promptly if you see any inconsistency in your grades (seven homeworks, three quizzes and one midterm). Midterm 2 is in two weeks (4/10). It will cover materials from Chapters 3, 4 and 5 (5.1 and 5.2).

Announcements The first midterm will not be curved Don’t know how to do it Curving exams is overused and so uncreative. Instead, you are allowed to design your own grade distribution. The worksheet will be available for download soon and it is due on the day of the final exam.

Merge Sort A recursive sorting algorithm Procedure mergesort ( L = a1, …., an) if n > 1 then m = floor (n/2) L1 = a1, …., am L2= a m+1, …., an L = merge(mergesort(L1, mergesort(L2)) {L is sorted into elements in nondecreasing order}

Merge Sort Procedure merge ( L1, L2 sorted lists) L= empty list while L1 and L2 are both nonempty begin remove smaller of first element of L1 and L2 from the list and put it at the right end of L if removal of this elemtn makes one list empty, then remove all elements from the other list and append them to L. {L is sorted into elements in increasing order} L1 L2 L

The time complexity if O (n log n) ! (next time). 8 2 4 6 9 7 10 1 5 3 7 10 1 5 3 8 2 4 6 9 8 2 4 6 9 5 3 7 10 1 6 9 7 10 1 4 8 2 5 3 8 2 7 10 The time complexity if O (n log n) ! (next time).

Analyzing Complexity of Merge Sort Let’s suppose that n ( the number of elements in the list) is a power of 2 (n=2m). This makes analysis easier. 2m 2m-1 2m-2 Level 1 Level 2

At level k, there are 2k lists, each with 2m-k elements. How many levels do we have? At level k, there are how many mergers ? (2k-1) How many comparisons are need to merge two sorted list of size 2m-k? ( 2m-k + 2m-k -1 ) 2m 2m-1 2m-2 Level 1 Level 2

2m 2m-1 2m-2 Level k At level k, the total number of comparisons is 2k-1 (2m-k+1 – 1)

Sum all these together : the total number of comparisons is The dominant term above is n log n. The time complexity is therefore O(n log n)! Questions? Comments?

5.1 Counting Counting ? Am I in grade school? In this Chapter, we will count with our heads, not with our fingers and toes! What problems can be solved with counting? Plenty! For example, How many comparisons does a sorting algorithm perform? How many attempts is needed to crack a code/password? What is the probability of two students in this class having the same birthday?