2.2 Algorithms 26-Jun-19.

Slides:



Advertisements
Similar presentations
13-Jun-14 OOP features of Jeroo. Overview In this presentation we will discuss these topics: OOP terminology Jeroo syntax constructors methods.
Advertisements

S.T.A.I.R.. General problem solving strategy that can be applied to a range problems.
11-May-15 Control Structures part 2. Overview Control structures cause the program to repeat a section of code or choose between different sections of.
Programming in Jessica By Joaquin Vila Prepared by Shirley White Illinois State University Applied Computer Science Department.
Jeroo Chapter 3 Problem Solving and Algorithms. Problem Solving and Algorithms  The story of Aunt Kay  A computer is a tool used to solve problems 
OPAPP “Grazing Area” Task  Class pictures and videos  Student examples of MOODLE assignments, responses, and feedback.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Programming Fundamentals (750113) Ch1. Problem Solving
Algebra Problems… Solutions
Lesson 4.1: Addition and Subtraction of 1 and 10
Key Stone Problem… Key Stone Problem… next Set 22 © 2007 Herbert I. Gross.
CS001 Introduction to Programming Day 5 Sujana Jyothi
CHAPTER 1: INTRODUCTION TO COMPUTER SCIENCE Introduction to Computer Science Using Ruby (c) 2012 Ophir Frieder et al.
Welcome to my conference! February th grade Guadalupe.
ECE 2300 Circuit Analysis Lecture Set #6 The Node Voltage Method with Voltage Sources.
Z-Town Technical Details Ben Trivett, Drew Switzer, Cameron Jett, Ryan Southard Department of Computer Science and Engineering The Ohio State University.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
25-Oct-15 Jeroo Code. Overview In this presentation we will discuss: How to write code in Jeroo How to run a Jeroo program.
Module 8 Lesson 5. Objective Relate the square to the cube, and describe the cube based on attributes.
Top Down Design Brent M. Dingle Texas A&M University Chapter 4 – Section 1 (and some from Mastering Turbo Pascal 5.5, 3 rd Edition by Tom Swan)
Using Formulas. Goal: 1.Plugging numbers into formulas. We use formulas to calculate values. 2.Use the formula d = rt to solve for different values.
Position and displacement. Objectives Describe motion in 1D using position, distance, and displacement. Analyze motion in 1D using position, distance,
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
1. 2 In what ways does your magazine use, develop or challenge forms and conventions of real music magazines? I tried to keep with convention when designing.
Frye’s phrases 3 rd 100. Near the car Between the lines.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
17-Feb-16 Methods. Overview In this presentation we will discuss these 4 topics: Main method vs. Jeroo methods Choosing behaviors to turn into methods.
Position and displacement. Describing motion Before you can predict an object’s motion, you need to be able to describe it. How do we describe an object’s.
11-Jun-16 Algorithms 2.2. Overview In this presentation we will discuss: What is an algorithm? 5 steps in developing an algorithm A Jeroo example.
Methods 9-Mar-17.
Fry Phrase List 3.
Goal Setting: Strategic Planning
ESSENTIAL WORDS.
Effective Time Management
Algorithms and Problem Solving
AP CSP: The Need for Programming Languages and Algorithms
Control Structures part 2
A TEACHER NEW AT MAPPING ASKS STUDENTS TO MAP
Module 3 – Part 2 Node-Voltage Method with Voltage Sources
Pythagorean Theorem MACC.8.G Apply the Pythagorean Theorem to determine unknown side lengths in right triangles in real-world and mathematical problems.
Copyright © 2008 by Helene G. Kershner
POD (5 minutes) *Turn to the first empty EVEN page in your notebook.)
Jeroo Code 18-Jul-18.
2.2 Algorithms 21-Jul-18.
Loops We have already seen instances where a robot needs to repeat instructions to perform a task turnRight(); moveMile(); Harvesting beepers in a field.
Copyright © 2008 by Helene G. Kershner
Have you ever conducted an experiment before
Programming – Touch Sensors
OOP features of Jeroo 8-Nov-18.
Sparse and Redundant Representations and Their Applications in
CS 139 – Programming Fundamentals
Programming Fundamentals (750113) Ch1. Problem Solving
A TEACHER NEW AT MAPPING ASKS STUDENTS TO MAP
CS305, HW1, Spring 2008 Evaluation Assignment
Algorithms and Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Flowcharts and Pseudo Code
START.
Four Key Elements of Solution-Focused Therapy (that you can use with any therapeutic approach) Jeff Chang, Ph.D., R.Psych. Athabasca University & Calgary.
Workshop for Programming And Systems Management Teachers
Programming Fundamentals (750113) Ch1. Problem Solving
Control Structures part 2
Computational Thinking
OOP features of Jeroo 3-Jul-19.
Indentation & Comments
Control Structures VB part 2
IF 1-Jul-19.
Jeroo Code 7-Sep-19.
Presentation transcript:

2.2 Algorithms 26-Jun-19

Overview In this presentation we will discuss: What is an algorithm? 5 steps in developing an algorithm Examples: An everyday example A Jeroo example

An algorithm is... We will cover each step in detail A plan for solving a problem 5 steps in algorithm development Describe the problem clearly We will cover each step in detail

Step 1: describe the problem Not as easy as it seems. Common defects of problem descriptions: relies on unstated assumptions is ambiguous is incomplete has contradictions Natural spoken languages are not very precise. It’s the developer’s job to spot any of these problems BEFORE any problem solving happens.

Step 2 : Analyze the problem Similar to a mathematician determining the given factors and what must be proven in a complex set of equations. Ask lots of questions: What information/resources are available? What different environments must the solution work in? What relationships exist between parts? What determines a complete solution? (When am I done?)

Example Problem Step 1 : Describe the problem I need to send a birthday card to my brother, Mark. Step 2: Analyze (think about the problem) I don’t have a card. I prefer to buy a card rather than make one myself.

Step 3: Develop a high-level algorithm High level algorithm = An overview. Not detailed. Birthday Card example: I need to buy a card for my brother Mark Step 3: High Level Algorithm (general solution) Go to a store that sells cards Select and purchase a card Mail the card

Step 3: High-level algorithms Go to a store that sells cards Select and purchase a card Mail the card Lacks enough detail for a computer or robot to understand Which store? How will you get to the store? (bike, car, bus?) What kind of card does Mark like? (funny, risqué, outdoorsy?)

Step 4: Add detail. Refine the algorithm by adding detail Stepwise refinement= Keep adding levels of detail. To know how far to go: You need to know how it will ultimately be implemented Birthday card example Who is going? Me? Very little detail needed Another family member? Minimal detail Someone unfamiliar with the area? Lots of detail about directions A robot? Minute detail.

Take some time Here is the high-level algorithm: Go to a store that sells cards Select and purchase a card ** Mail the card ** Add at least 4 detailed steps needed to accomplish the 3rd part of the high-level algorithm listed above: Mail the card What needs to be done after you have purchased the card so that you can successfully mail the card?

This problem is NOT clearly defined A Jeroo example Step 1: the problem A Jeroo should travel from a corner of an island to the middle. This problem is NOT clearly defined

A Jeroo example Step 1: the problem clearly defined. 4 Jeroos start on Ricochet island at (2,0,EAST); (0,19,SOUTH); (21,23,WEST); (23,4,NORTH);with no flowers. Each Jeroo must do 4 things: leave the room (it's dark, follow the wall on your right until you get to an opening, then turn right) keep going until you find a flower and pick it turn left and keep going until you find a net and disable it turn right and then keep going until you find the flower field and you're ready for breakfast. There are no other nets, or water traps on the island.

Step 2 : Analyze the problem It only needs to work on 1 island: Ricochet island Each Jeroo is already facing the right direction when it is instantiated Every Jeroo can follow the same set of directions as long as it uses loops To keep the program short, divide each part into methods

Using the Ricochet Problem: If you don’t understand how the program is supposed to work, how can you solve it? Analyze where there are loops and turns The problem can be solved in 4 parts: Leave Room getFlower toNet enterField To understand the problem trace the path of the Jeroos across the island to see where they need to go.

Jeroo Example, Step 3 There are 4 things to do: This is the high level algorithm There are 4 things to do: Leave the room Find and pick a flower Find and disable a net Enter the flower field method getBreakfast() { // Leave the room //Find and pick a flower //Find and disable a net //Enter the flower field } Simplify the program By putting them in a method

Good programming practices Detailed Algorithm: ( part 1) 1. Leave the Room follow the water on your right until you get to an opening then turn right while( isWater(RIGHT) ) { hop(); } turn(RIGHT); method getBreakfast() { // Leave the room //Find and pick a flower //Find and disable a net //Enter the flower field } Comments, or method names, clearly mirror the high-level algorithm

Take some time for Step 4 Here is the high-level algorithm: Leave the room Find and pick a flower ** Find and disable a net ** Enter the flower field Add at least 3 detailed steps needed to accomplish the 3rd part of the high-level algorithm listed above: Find and disable a net What needs to be done after you pick the flower to be able to successfully find and disable a net on the way to the flower field?

Step 5: Review First: Work through the algorithm step by step and determine whether or not it actually solves the problem. Then ask: Does it solve a particular problem or a general one? Should it be generalized? A program to find the area of a circle with radius = 5.2 could easily be generalized to find the area of any circle with the addition of a single variable. Can it be simplified? Is this solution similar to something already done?

The End