The Beauty and Joy of Computing Lecture #6 Algorithms I UC Berkeley EECS Sr Lecturer SOE Dan Garcia.

Slides:



Advertisements
Similar presentations
College of Information Technology & Design
Advertisements

Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the five essential properties of an algorithm.
1 Module 2: Fundamental Concepts Problems Programs –Programming languages.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Lecture 2: Fundamental Concepts
1 Lecture 1: Course Overview Course: CSE 360 Instructor: Dr. Eric Torng TA: Huamin Chen.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
CS /29/2004 (Recitation Objectives) and Computer Science and Objects and Algorithms.
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 1 Program Design
Recursion Chapter 7. Chapter 7: Recursion2 Chapter Objectives To understand how to think recursively To learn how to trace a recursive method To learn.
The Beauty and Joy of Computing Lecture #6 Algorithms Alan Turing ( ) would have turned 100 this year. He was a brilliant British mathematician.
BIT Presentation 4.  An algorithm is a method for solving a class of problems.  While computer scientists think a lot about algorithms, the term.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a CSC 201 Analysis and Design of Algorithms Lecture 03: Introduction to a lgorithms.
Invitation to Computer Science, Java Version, Second Edition.
Recursion Chapter 7. Chapter Objectives  To understand how to think recursively  To learn how to trace a recursive method  To learn how to write recursive.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Major objective of this course is: Design and analysis of modern algorithms Different variants Accuracy Efficiency Comparing efficiencies Motivation thinking.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
CSC 211 Data Structures Lecture 13
The Beauty and Joy of Computing Lecture #6 Algorithms MIT researchers recently created an algorithm which they say will be able to predict what topics.
Institute for Personal Robots in Education (IPRE)‏ CSC 170 Computing: Science and Creativity.
CS221 Algorithm Basics. What is an algorithm? An algorithm is a list of instructions that transform input information into a desired output. Each instruction.
CMP-MX21: Lecture 5 Repetitions Steve Hordley. Overview 1. Repetition using the do-while construct 2. Repetition using the while construct 3. Repetition.
Programming Fundamentals. Thinking about Programming Robots are made to perform useful tasks. Each robot is designed to solve a specific problem, in a.
Algorithms Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006 by Maria Litvin, Gary Litvin,
CS404 Design and Analysis of Algorithms BBy DDr. M V S Peri Sastry BB.E, PhD(BITS-Pilani)
Chapter 15: Recursion. Objectives In this chapter, you will: – Learn about recursive definitions – Explore the base case and the general case of a recursive.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
The single most important skill for a computer programmer is problem solving Problem solving means the ability to formulate problems, think creatively.
1 Recursive algorithms Recursive solution: solve a smaller version of the problem and combine the smaller solutions. Example: to find the largest element.
The Beauty and Joy of Computing Lecture #7 Algorithms II minors-delete-activity/story?id= /
In the news: A recently security study suggests that a computer worm that ran rampant several years ago is still running on many machines, including 50%
UC Berkeley EECS Sr Lecturer SOE Dan Garcia printing-aims-to-prevent-a-piracy-plague/ Quest.
Chapter 15: Recursion. Recursive Definitions Recursion: solving a problem by reducing it to smaller versions of itself – Provides a powerful way to solve.
Chapter 15: Recursion. Objectives In this chapter, you will: – Learn about recursive definitions – Explore the base case and the general case of a recursive.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 1 An Introduction to Visual Basic.NET and Program Design.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
The Beauty and Joy of Computing Lecture #6 Algorithms I Jon Kotker UC Berkeley EECS 2010, 2013 Microsoft
Introduction to Algorithms
Algorithms and Problem Solving
Algorithms CSE 120 Spring 2017 Instructor: Teaching Assistants:
COP 3503 FALL 2012 Shayan Javed Lecture 15
Data Structures and Algorithms
GC211Data Structure Lecture2 Sara Alhajjam.
Creativity in Algorithms
An Introduction to Visual Basic .NET and Program Design
Recursion "To understand recursion, one must first understand recursion." -Stephen Hawking.
Creativity in Algorithms
Objective of This Course
Programming Fundamentals (750113) Ch1. Problem Solving
Coding Concepts (Basics)
Algorithms CSE 120 Winter 2018 Instructor: Teaching Assistants:
Global Challenge Walking for Water Lesson 2.
Asst. Dr.Surasak Mungsing
Algorithms and Problem Solving
Introduction to Algorithms
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Discrete Mathematics and its Applications
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Presentation transcript:

The Beauty and Joy of Computing Lecture #6 Algorithms I UC Berkeley EECS Sr Lecturer SOE Dan Garcia

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (2) Garcia What is an algorithm? ● 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. ● The concept of algorithms, however, is far older than computers.

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (3) Garcia ● Dances, ceremonies, recipes, and building instructions are all conceptually similar to algorithms. ● Babylonians defined some fundamental mathematical procedures ~3,600 years ago. ● Genes contain algorithms! Early Algorithms Photo credit: Daniel Niles

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (4) Garcia Algorithms You've Seen in CS10 ● Length of word ● Whether a word appears in a list ● Interact with the user (ask) ● Word Comparisons (You wrote one for HW1!) ● Sort a List (see lab!) ● Make this a block!

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (5) Garcia Algorithms You Might Have Heard Of Luhn algorithm Credit card number validation Deflate Lossless data compression PageRank Google’s way of measuring “reputation” of web pages EdgeRank Facebook’s method for determining what is highest up on your news feed

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (6) Garcia Important Terms Sequencing Application of each step of an algorithm in order (sometimes: find order) Selection Use of Boolean condition to select execution parst Iteration Repetition of part of an algorithm until a condition is met Recursion Repeated application of the same part of algorithm on smaller problems

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (7) Garcia Properties of Algorithms ● Algorithm + Algorithm = Algorithm ● Part of Algorithm = Algorithm ● Algorithms can be efficient or inefficient given a comparison algorithm ● Several algorithms may solve the same problem

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (8) Garcia TOTAL Correctness Always reports, and the answer is always correct. PARTIAL Correctness Sometimes reports, and the answer is always correct when it reports. Algorithm Correctness We don't only want algorithms to be fast and efficient; we also want them to be correct! We also have probabilistic algorithms that have a certain probability of returning the right answer.

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (9) Garcia How to Express Algorithms… A programmer’s spouse tells him: “Run to the store and pick up a loaf of bread. If they have eggs, get a dozen.” The programmer comes home with 12 loaves of bread. Algorithms need to be expressed in a context-free, unambiguous way for all participants

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (10) Garcia Ways to Express Algorithms ● Natural Language ● Pseudo Code ● Programming Language ● …or in any other information conveying way!

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (11) Garcia Programming Languages C/C++ Good for programming that is close to hardware Java/C# Portable code Python/Perl/TclTK Fast to write and portable BASIC/BYOB/SNAP Good for teaching programming concepts All programming languages can be used to implement (almost) any algorithm!

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (12) Garcia Choosing a Technique ● Most problems can be solved in more than one way, i.e., multiple algorithms exist to describe how to find the solution. ● The right language makes formulating algorithms easier and clearer ● Not all of these algorithms are created equal. Very often we have to make some trade-offs when we select a particular one. ● There are unsolvable problems!

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (13) Garcia ● Algorithms are conceptual definitions of how to accomplish a task and are language agnostic, usually written in pseudo-code. ● Find max value in list ● Set (a temporary variable) the max as the first element ● Go through every element, compare to max, and if it’s bigger, replace the max ● Return the max  A function or procedure is an implementation of an algorithm, in a particular language.  Find max value in list Algorithms vs. Functions & Procedures

UC Berkeley “The Beauty and Joy of Computing” : Algorithms I (14) Garcia ● The concept of an algorithm has been around forever, and is an integral topic in CS. ● Algorithms are well- defined procedures that can take inputs and produce output. Programming languages help us express them. ● We're constantly dealing with trade- offs when selecting / building algorithms. ● Correctness is particularly important and testing is the most practical strategy to ensure it. ● Many write tests first! Summary