CS001 Introduction to Programming Day 5 Sujana Jyothi

Slides:



Advertisements
Similar presentations
Working With Algorithm and Flowcharts
Advertisements

Slide 1 Today you will: Review knowledge and understanding of systems Understand what a system is and what it consists of Apply this understanding by working.
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
The LC-3 – Chapter 6 COMP 2620 Dr. James Money COMP
Basic Programming Concepts INTRO TO PROGRAMMING. Questions to answer  What is a computer program?  What are computer instructions  How is a program.
Unit 7.6 Lesson 2 Goals Identify and use flowchart symbols. Plan a sequence of events and incorporate them into a flowchart. Create a simple flowchart.
Basics of Computer Programming Web Design Section 8-1.
Tutorial #6 PseudoCode (reprise)
 Draft timetable has the same times as this semester: - ◦ Monday 9:00 am to 12:00 noon, 1:00 pm to 3:00 pm. ◦ Tuesday 9:00 am to 12:00 noon, 1:00 pm.
Problem Solving for Programming Session 5 Problems involving arithmetic.
CS001 Introduction to Programming Day 3 Sujana Jyothi
Tutorial #7 Flowcharts (reprise) Program Design. Introduction We mentioned it already, that if we thing of an analyst as being analogous to an architect,
Program Design and Development
Algorithm Design CS105. Problem Solving Algorithm: set of unambiguous instructions to solve a problem – Breaking down a problem into a set of sub- problems.
CMT1000: Introduction to Programming Ed Currie Lecture 2A: Pizza.
1 Chapter 8 Designing Small Programs. 2 A ‘Procedure’ v A set of instructions which describe the steps to be followed in order to carry out an activity.
Programming Fundamentals (750113) Ch1. Problem Solving
Flow Charts. Thinking Creatively Flow Charts START END Is A==6? No A = 1 Yes Print A A = A + 1.
CSC103: Introduction to Computer and Programming
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 02.
1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems.
Algorithms In general algorithms is a name given to a defined set of steps used to complete a task. For example to make a cup of tea you would fill the.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
For this unit, you will develop a new swimming / leisure business. 2. You will need to think of a name & concept for the business. 3. Over the.
Section 4 - Functions. All of the programs that we have studied so far have consisted of a single function, main(). However, having more than one function.
Top-Down Design Damian Gordon. Top-Down Design Top-Down Design (also known as stepwise design) is breaking down a problem into steps. In Top-down Design.
Task Analysis TECM 4250 Dr. Lam. What is Task Analysis? Task analysis is typically a method used in usability testing and user-centered design for the.
Learn about the system life cycle Plan the outline of your project
Sequence Damian Gordon. Pseudocode When we write programs, we assume that the computer executes the program starting at the beginning and working its.
Mug Tea bag Kettle Milk Sugar (only if you like it in your tea) A spoon Biscuits A plate for the biscuits.
Software Development. Software Development Loop Design  Programmers need a solid foundation before they start coding anything  Understand the task.
Slide 1 Controlling Sequences of Events Traffic lights Event table.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
Algorithms and Pseudocode
Computer Control Using computers to do tasks. What are Computers used for? ringing your alarm clock. microwaving your breakfast checking for text messages.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Pseudocode Skill Area Materials Prepared by Dhimas Ruswanto, BMm.
Chapter 12 Theory of Computation Introduction to CS 1 st Semester, 2014 Sanghyun Park.
Changing Backgrounds 3 methods of achieving this.
Sequences, Modules and Variables David Millard
Comp1004: Programming in Java II Computational Thinking.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
Algorithms and Flowcharts
HOW TO MAKE A GOOD CUP OF TEA SKW 3061 ENGLISH WORKPLACE MISS GURMINDERJEET KAUR MOHAMAD SHAZRYL B. MOHD SHUKOR B01SPS13F
Building Good Solutions David Millard
Software Development.
Introduction to programming
FLOWCHARTS Part 1.
Algorithm and Ambiguity
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Introduction To Flowcharting
Algorithm and Ambiguity
Yenka Portfolio Level for this topic: Student Name : My Levels
Algorithms Today we will look at: what the word algorithm means
Algorithms Y10 Introduction.
Problem Solving Techniques
Programming Languages
Chapter 6 : Algorithm Development
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
“In the midst of chaos, there is also opportunity” - Sun Tzu
Algorithm and Ambiguity
Computer Science Core Concepts
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Prepared By: Deborah Becker
Flowcharts Activity One
“In the midst of chaos, there is also opportunity” - Sun Tzu
Presentation transcript:

CS001 Introduction to Programming Day 5 Sujana Jyothi

2 What will you learn today? Algorithm Development Stepwise refinement

Algorithm Development In order for a computer to carry out some task, it has to be supplied with a program, which is an implementation of an algorithm. The most widely used notations for developing algorithms are flowcharts and pseudo-code. A flowchart is a diagram containing lines representing all the possible paths through the program. Pseudo-code is a form of “stylized” (or “structured”) natural language.

Algorithm Development

The designer of an algorithm must ensure: Preciseness of the algorithm (no ambiguities) All possible circumstances are handled The algorithm is executable Termination of the algorithm

Stepwise refinement Break a complex problem down into a number of simpler steps, each of which can be solved by an algorithm which is smaller and simpler than the one required to solve the overall problem. Refinement of the algorithm continues in this manner until each step is sufficiently detailed. — Refinement means replacing existing steps /instructions with a new version that fills in more details.

Stepwise refinement Example: Making tea. Suppose we have a robot which carries out household tasks. We wish to program the robot to make a cup of tea. An initial attempt at an algorithm might be: 1. Put tea leaves in pot 2. Boil water 3. Add water to pot 4. Wait 5 minutes 5. Pour tea into cup

Stepwise refinement These steps are probably not detailed enough for the robot. We therefore refine each step into a sequence of smaller steps: 1. Put tea leaves in pot might be refined to 1.1 Open box of tea 1.2 Extract one spoonful of tea leaves 1.3 Tip spoonful into pot 1.4 Close box of tea

Stepwise refinement – contd. 2. Boil water might be refined to 2.1. Fill kettle with water 2.2 Switch on kettle 2.3 Wait until water is boiled 2.4 Switch off kettle 5. Pour tea into cup might be refined to 5.1. Pour tea from pot into cup until cup is full

Stepwise refinement – contd. Some of the sub-algorithms need further refinement. For example, the step 2.1. Fill kettle with water could be refined to Put kettle under tap Turn on tap Wait until kettle is full Turn off tap

Stepwise refinement – contd. The above algorithm consists of a sequence of steps, each of which will be executed exactly once and in order – termination of the last step implies termination of the algorithm. However, algorithms with only sequences of steps can’t do much… — Example: What happens if the tea-box is empty?

Stepwise refinement – contd. If the tea-box is empty we wish to specify an extra step: Get new box of tea from cupboard We can express this by rewriting step 1.1 as Take tea box from shelf If box is empty then get new box from cupboard Remove lid from box (More complicated conditions can use AND, OR, NOT)

Events

Stepwise approach to programming through Scratch /* Hello World program */ #include main() { printf("Hello World"); }

Statement

Boolean Expression

Conditions

Looping

Variables 1 (true)

Example to add two numbers Write an algorithm to add two numbers. The numbers should be taken from the keyboard and stored in variables.