1 Algorithms and Problem Solving. 2 Outline  Problem Solving  Problem Solving Strategy  Algorithms  Sequential Statements  Examples.

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

Write a program step by step. Step 1: Problem definition. Given the coordinate of two points in 2-D space, compute and print their straight distance.
Chapter 1: An Overview of Computers and Programming Languages
Programming Tools for Solution Development Module 3 Lesson 2 Assignment: Notes.
Algorithms and Problem Solving
INTRODUCTION TO PROGRAMMING
© Janice Regan Problem-Solving Process 1. State the Problem (Problem Specification) 2. Analyze the problem: outline solution requirements and design.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Introduction to Computers and Programming Lecture 5 New York University.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
Introduction to Computers and Programming Lecture 5 Boolean type; if statement Professor: Evan Korth New York University.
Copyright 2006 by Pearson Education 1 Building Java Programs Chapter 3: Parameters, Return, and Interactive Programs with Scanner.
Unit 171 Algorithms and Problem Solving  Introduction  Algorithm Design  Algorithm Properties  Algorithm Control Flow  Examples  Comparing Algorithms.
Slides prepared by Rose Williams, Binghamton University Chapter 3 Flow of Control Loops in Java.
Chapter 1 pp 1-14 Properties of Algorithms Pseudocode.
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
Lecture 7. Review Homework 1 (sample solution) Project 1 will be assigned next week –Draw a picture (whatever you want) in the world by using turtles.
Chapter 2: Algorithm Discovery and Design
Review Algorithm Analysis Problem Solving Space Complexity
Introduction to Methods
Writing algorithms using the while-statement. Previously discussed Syntax of while-statement:
Algorithms: Selected Exercises Goals Introduce the concept & basic properties of an algorithm.
An ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time Let's examine the four parts of this.
1 BUILDING JAVA PROGRAMS CHAPTER 2 PRIMITIVE DATA AND DEFINITE LOOPS.
Week 1 - Friday.  What did we talk about last time?  Our first Java program.
What does a computer program look like: a general overview.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
IXA 1234 : C++ PROGRAMMING CHAPTER 1. PROGRAMMING LANGUAGE Programming language is a computer program that can solve certain problem / task Keyword: Computer.
Control Structures (A) Topics to cover here: Introduction to Control Structures in the algorithmic language Sequencing.
Assignment statements using the same variable in LHS and RHS.
1 An Example. Problem Using OCD, design and implement a program that computes the area and circumference of an Australian Rules Football field, which.
1 An Example. Problem Using OCD, design and implement a program that computes the area and circumference of an Australian Rules Football field, which.
Chapter Algorithms 3.2 The Growth of Functions 3.3 Complexity of Algorithms 3.4 The Integers and Division 3.5 Primes and Greatest Common Divisors.
Basic problem solving CSC 111.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Arithmetic expressions containing Mathematical functions.
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
Working with floating point expressions. Arithmetic expressions Using the arithmetic operators: and brackets (... ), we can construct arithmetic expression.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Algorithms and Pseudocode
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Methods.
Programming. In your own words, explain what an algorithm is, and give an example of how people use algorithms every day.
CS 100Lecture 11 Introduction to Programming n What is an algorithm? n Input and output n Sequential execution n Conditional execution Reading: Chapter.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Problem Solving.  Similar to Solving Math Word Problem  Read the Problem  Decide how to go about Solving the Problem  Solve the Problem  Test the.
Chapter 3 Introducing Java. Objectives and Goals 1. Define terminology associated with object- oriented programming. 2. Explain why Java is a widely used.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Program design Program Design Process has 2 phases:
Algorithms and Problem Solving
Unit 3: ALGORITHMS AND FLOWCHARTS
Chapter 2 Elementary Programming
CS111 Computer Programming
Algorithm and Ambiguity
Lecture 2: Introduction to Algorithms
COMS W1004 Introduction to Computer Science and Programming in Java
Computing Adjusted Quiz Total Score
Programming Problem solving Debugging
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
CS 200 Primitives and Expressions
Lecture Notes – Week 4 Chapter 5 (Loops).
Algorithms and Problem Solving
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
Type Topic in here! Created by Educational Technology Network
WJEC GCSE Computer Science
WRITING AN ALGORITHM, PSEUDOCODE, AND FLOWCHART LESSON 2.
Presentation transcript:

1 Algorithms and Problem Solving

2 Outline  Problem Solving  Problem Solving Strategy  Algorithms  Sequential Statements  Examples

3 Problem Solving  Solving a problem means that we know the way or the method to follow manually from the start till the end.  Having the method known, the same method is used by the computer to solve the problem but faster with higher precision.  If we do not know how to solve a problem ourselves, the computer will not be of any help in this regard.  The strategy for solving a problem goes through the following stages:  Analysis: in this stage, we should find what the problem should do.  Design : the way or method of how your problem is solved is produced  Implementation: the method found in design is then coded here in a given programming language.  Testing: here we verify that the program written is working correctly  Deployment : finally the program is ready to use

4 Problem Solving Strategy

5 Algorithms  An algorithm is a sequence of instructions that solve a problem with the following properties:  No ambiguity in any instruction  No ambiguity which instruction is next  Finite number of instructions  Execution must halt  The description of the instructions can be given in English like statements called pseudo-code  The flow control of instructions has three types:  Sequential  Selection  Iteration

6 Sequential Statements  Instructions in this type are executed one after the other in sequence  These statements include:  Assignment statement  Method calls

7 Example1  Write a program that assigns the Cartesian coordinates of two points (x1, y1) and (x2, y2) and displays the distance between them using the following formula.  Algorithm: »x1 = 1 »y1 = 1 »x2 = 4 »y2 = 6 »distance = sqrt( (x2 – x1) ^ 2 + (y2 – y1) ^ 2 ) »print distance

8 Example1 (cont'd)  Java code: public class Distance { public static void main(String[] args) { double x1, y1, x2, y2, dist; x1 = 1.0; y1 = 1.0; x2 = 4.0; y2 = 6.0; dist = Math.sqrt(Math.pow(x2-x1,2)+ Math.pow(y2-y1,2)); System.out.println("The distance is " + dist); }

9 Example2  Write a program that finds the area of a triangle given the length of its sides: a, b, c. Use a = 3, b = 4, c = 5 to test your solution.  Algorithm: »a = 3 »b = 4 »c = 5 »s = (a + b + c) / 2 »area = sqrt( s* (s – a) * (s – b) * (s – c) ) »print area

10 Example2 (cont'd)  Java code: public class Distance { public static void main(String[] args) { double a, b, c, area; a = 3.0; b = 4.0; c = 5.0; s = (a + b + c ) / 2.0; area = Math.sqrt(s * (s - a) * (s – b) * (s – c) ); System.out.println("The area is " + area); }