What is an Algorithm? TechNights October 17, 2016.

Slides:



Advertisements
Similar presentations
Order of complexity. Consider four algorithms 1.The naïve way of adding the numbers up to n 2.The smart way of adding the numbers up to n 3.A binary search.
Advertisements

Dynamic Programming 25-Mar-17.
Algorithm Design Techniques
Back to Sorting – More efficient sorting algorithms.
 Review: The Greedy Method
Chapter 7 Sorting Part II. 7.3 QUICK SORT Example left right pivot i j 5 > pivot and should go to the other side. 2 < pivot and should go to.
Dynamic Programming.
Introduction to Algorithms Greedy Algorithms
Divide and Conquer Yan Gu. What is Divide and Conquer? An effective approach to designing fast algorithms in sequential computation is the method known.
Types of Algorithms.
Anany Levitin ACM SIGCSE 1999SIG. Outline Introduction Four General Design Techniques A Test of Generality Further Refinements Conclusion.
For Monday Read 10.3 Homework: –Chapter 10, exercise 10.
Quicksort File: D|\data\bit143\Fall01\day1212\quicksort.sdd BIT Gerard Harrison Divide and Conquer Reduce the problem by reducing the data set. The.
15-May-15 Dynamic Programming. 2 Algorithm types Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Divide and Conquer.
Quicksort Quicksort     29  9.
Outline 1. General Design and Problem Solving Strategies 2. More about Dynamic Programming – Example: Edit Distance 3. Backtracking (if there is time)
16-May-15 Dynamic Programming. 2 Algorithm types Algorithm types we will consider include: Simple recursive algorithms Backtracking algorithms Divide.
Algorithm Strategies Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
CompSci Recursion & Minimax Playing Against the Computer Recursion & the Minimax Algorithm Key to Acing Computer Science If you understand everything,
Roundtable Clear your desks. Only one paper and pencil. Each student writes one answer and passes the paper to the right. Everyone must write an answer.
Introduction to Algorithms Chapter 7: Quick Sort.
CPSC 171 Introduction to Computer Science More Efficiency of Algorithms.
General Computer Science for Engineers CISC 106 James Atlas Computer and Information Sciences 10/23/2009.
© 5/7/2002 V.S. Subrahmanian1 Knapsack Problem Notes V.S. Subrahmanian University of Maryland.
Lecture 33 CSE 331 Nov 20, Homeworks Submit HW 9 by 1:10PM HW 8 solutions at the end of the lecture.
Chapter 10: Algorithm Design Techniques
S: Application of quicksort on an array of ints: partitioning.
CSC 2300 Data Structures & Algorithms March 20, 2007 Chapter 7. Sorting.
1 Algorithm Design Techniques Greedy algorithms Divide and conquer Dynamic programming Randomized algorithms Backtracking.
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Design and Analysis of Algorithms - Chapter 11 Algorithm An algorithm is a.
Dave Risch. Project Specifications There is a “knapsack” that you want to fill with the most valuable items that are available to you. Each item has a.
New Mexico Computer Science For All Introduction to Algorithms Maureen Psaila-Dombrowski.
Computer Science 101 Fast Searching and Sorting. Improving Efficiency We got a better best case by tweaking the selection sort and the bubble sort We.
Fundamentals of Algorithms MCS - 2 Lecture # 7
Computer Science 101 A Survey of Computer Science QuickSort.
Vocabulary Strategies
+ Dividing with Partial Quotients. + Instructions 1. Use a separate piece of paper to show your work and write your answers 2. SHOW PROOF for the operation.
Computer Science 101 Fast Algorithms. What Is Really Fast? n O(log 2 n) O(n) O(n 2 )O(2 n )
Types of Algorithms. 2 Algorithm classification Algorithms that use a similar problem-solving approach can be grouped together We’ll talk about a classification.
Decision Problems Optimization problems : minimum, maximum, smallest, largest Satisfaction (SAT) problems : Traveling salesman, Clique, Vertex-Cover,
1 Data Structures CSCI 132, Spring 2014 Lecture 1 Big Ideas in Data Structures Course website:
Lecture 8 CSE 331. Main Steps in Algorithm Design Problem Statement Algorithm Problem Definition “Implementation” Analysis n! Correctness+Runtime Analysis.
CSE 340: Review (at last!) Measuring The Complexity Complexity is a function of the size of the input O() Ω() Θ() Complexity Analysis “same order” Order.
QuickSort Choosing a Good Pivot Design and Analysis of Algorithms I.
Backtracking & Brute Force Optimization Intro2CS – weeks
Sorting Lower Bounds n Beating Them. Recap Divide and Conquer –Know how to break a problem into smaller problems, such that –Given a solution to the smaller.
CompSci Recursion & Minimax Recursion & the Minimax Algorithm Key to Acing Computer Science If you understand everything, ace your computer science.
1Computer Sciences Department. 2 QUICKSORT QUICKSORT TUTORIAL 5.
A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding.
Ch3 /Lecture #4 Brute Force and Exhaustive Search 1.
Dynamic Programming 26-Apr-18.
Data Structures Lab Algorithm Animation.
CMSC201 Computer Science I for Majors Lecture 23 – Sorting
Friday 9/15/17 Notebook Entry: Think about how your group worked together to design and build your boat. What do you think went well? What do you think.
Lecture 31 CSE 331 Nov 14, 2016.
MA/CSSE 473 Day 16 Answers to your questions Divide and Conquer
The Need for Programming Languages
Types of Algorithms.
Lecture 31 CSE 331 Nov 13, 2017.
Algorithm Design Methods
Divide and Conquer Mergesort Quicksort Binary Search Selection
Types of Algorithms.
Dynamic Programming 23-Feb-19.
Types of Algorithms.
Algorithm “Quiz”.
Lecture 32 CSE 331 Nov 12, 2014.
Mod 3 Lesson 2 Me First! Sorting
Lecture 27 CSE 331 Nov 4, 2016.
b c b b 30 20 15 a a a Create one of your own… b b c
Presentation transcript:

What is an Algorithm? TechNights October 17, 2016

An Algorithm Is… A step-by-step set of instructions for a specific task Clear and organized What algorithms do you know about?

Lego Construction Algorithm Teams of four Look at the picture and build the object Write directions on the paper (an algorithm!) Trade pieces and directions with another team Follow the directions to build the object—2 minutes! Compare with the picture A total of 5 minutes for this exercise.

Lego Construction Algorithm Can we do better? Give them 10 minutes

Problem-Solving Strategies Our Toolbox Problem-Solving Strategies

“Brute Force”

How would you find the piece that fits? Jigsaw – each girl should have one piece Give them 3-4 minutes

“Divide and Conquer” Give everyone a number. Sort yourselves! Recursion!

Sort yourselves By Birthdays! Volunteers – choose a girl to be a pivot for a couple groups Remember Quicksort?

Bisection How do we search effectively? We run a binary search on the girls Whose birthday is closest to today?

Bisection

Bisection

Bisection

Bisection

“Greedy” Knapsack Problem

Limit: 20 pounds A. $1, 3 pounds B. $9, 4 pounds C. $5, 2 pounds D. $9, 6 pounds E. $11, 7 pounds F. $6, 3 pounds G. $12, 5 pounds 1. Choose the best item 2. If it fits, put it in and go to step 1 3. If it doesn’t, put it aside and go to step 1 4. If there are no more items, stop 5. If your bag is full, stop 6. Otherwise, go to step 1

Choose the most ‘dense’ 1. Choose the best item 2. If it fits, put it in and go to step 1 3. If it doesn’t, put it aside and go to step 1 4. If there are no more items, stop 5. If your bag is full, stop 6. Otherwise, go to step 1 A. $1, 3 pounds = 0.33 B. $9, 4 pounds = 2.25 C. $5, 2 pounds = 2.5 D. $9, 6 pounds = 1.5 E. $11, 7 pounds = 1.6 F. $6, 3 pounds = 2 G. $12, 5 pounds = 2.4 Answer they should get: $50 Also the optimal answer

How do I write a clear algorithm? What strategies can I use? Reflection How do I write a clear algorithm? What strategies can I use?