Lecture 7 Algorithm Design & Implementation. All problems can be solved by employing any one of the following building blocks or their combinations 1.

Slides:



Advertisements
Similar presentations
CS101: Introduction to Computer programming
Advertisements

1 CS101 Introduction to Computing Lecture 17 Algorithms II.
Prof. B. I. Khodanpur HOD – Dept. of CSE R. V. College of Engineering
Flowcharts Amir Haider Lecturer NFC IEFR. Introduction The flowchart is a means of visually presenting the flow of data through an information processing.
Reference :Understanding Computers
Flowchart TA. Maram Al-Khayyal.
ITEC113 Algorithms and Programming Techniques
Algorithm and Flowchart Questions
Program Design and Development
Programming Fundamentals (750113) Ch1. Problem Solving
The Program Design Phases
PRE-PROGRAMMING PHASE
Programming Logic and System Analysis
Fundamentals of C programming
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
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.
INTRODUCTION TO COMPUTING CHAPTER NO. 04. Programming Languages Program Algorithms and Pseudo Code Properties and Advantages of Algorithms Flowchart (Symbols.
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
CMSC 104: Peter Olsen, Fall 99Lecture 9:1 Algorithms III Representing Algorithms with pseudo-code.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
Algorithms & FlowchartsLecture 10. Algorithm’s CONCEPT.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
Concepts of Algorithms CSC-244 Unit Zero Pseudo code, Flowchart and Algorithm Master Prince Computer College Qassim University K.S.A.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
P ROGRAMMING L OGIC GWDA123 Sharon Kaitner, M.Ed. Winter 2015: Week 2.
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
Program Program is a collection of instructions that will perform some task.
How Computers Solve Problems Computers also use Algorithms to solve problems, and change data into information Computers can only perform one simple step.
Introduction to Problem Solving Programming is a problem solving activity. When you write a program, you are actually writing an instruction for the computer.
 Problem Analysis  Coding  Debugging  Testing.
Programming Logic and Design Fourth Edition, Introductory Chapter 2 Understanding Structure.
Program design Program Design Process has 2 phases:
Learning outcomes 5 Developing Code – Using Flowcharts
MANUPLATION OF FLOWCHARTS
Programming Languages
GC211Data Structure Lecture2 Sara Alhajjam.
ALGORITHMS AND FLOWCHARTS
CS1001 Programming Fundamentals 3(3-0) Lecture 2
Unit 2 Smarter Programming.
Lecture 2 Introduction to Programming
Algorithm Algorithm is a step-by-step procedure or formula or set of instruction for solving a problem Its written in English language or natural language.
Introduction to Computer Programming
Programming Fundamentals
2008/09/24: Lecture 6b CMSC 104, Section 0101 John Y. Park
ALGORITHMS AND FLOWCHARTS
PROBLEM SOLVING AND OFFICE AUTOMATION
Unit# 9: Computer Program Development
Problem Solving Techniques
Chapter 3: Program Statements
Programming Fundamentals (750113) Ch1. Problem Solving
Programming Fundamentals (750113) Ch1. Problem Solving
Understanding the Three Basic Structures
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
ALGORITHMS AND FLOWCHARTS
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
CSC128 FUNDAMENTALS OF COMPUTER PROBLEM SOLVING
How Are Algorithms Developed?
Programming Fundamentals (750113) Ch1. Problem Solving
PROGRAMMING FUNDAMENTALS Lecture # 03. Programming Language A Programming language used to write computer programs. Its mean of communication between.
Click to add Text Computers & Instructions. Computers are given instructions in the form of computer programs that are created through the development.
Lecture 6 Architecture Algorithm Defin ition. Algorithm 1stDefinition: Sequence of steps that can be taken to solve a problem 2ndDefinition: The step.
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
Programming Fundamentals (750113) Ch1. Problem Solving
Algorithms, Part 2 of 3 Topics Problem Solving Examples Pseudocode
WRITING AN ALGORITHM, PSEUDOCODE, AND FLOWCHART LESSON 2.
Presentation transcript:

Lecture 7 Algorithm Design & Implementation

All problems can be solved by employing any one of the following building blocks or their combinations 1. Sequences 2. Conditionals 3. Loops

A sequence of instructions that are executed in the precise order they are written in: statement block 1 statement block 2 statement block 3 statement block 1 statement block 2 statement block 3

Select between alternate courses of action depending upon the evaluation of a condition If ( condition = true ) statement block 1 Else statement block 2 End if statement block 1 condition TrueFalse statement block 2

Loop through a set of statements as long as a condition is true Loop while ( condition = true ) statement block End Loop condition True False statement block

We will first go through the problem statement and then present the algorithm in three different formats: 1. Pseudo code 2. Flowchart 3. Actual code

Convert a decimal number into binary

remainder

1. Let the decimal number be an integer x, x > 0 2. Let the binary equivalent be an empty string y 3. Repeat while x > 0 { Determine the quotient & remainder of x ÷ 2 y = CONCATENATE( remainder, y ) x = quotient } 4. Print “2”, y 5. Stop

Start Find quotient & remainder of x ÷ 2 Get x x >1 ? Stop y = CONC( x, remainder) x = quotient x is the decimal number y is the binary equivalent Flowchart of Decimal to Binary Conversion Yes No Print “2”, y

#include int main(){ long int decimalNumber,remainder,quotient; int binaryNumber[100],i=1,j; printf("Enter any decimal number: "); scanf("%ld",&decimalNumber); quotient = decimalNumber; while(quotient>1){ binaryNumber[i++]= quotient % 2; quotient = quotient / 2; } printf("Equivalent binary value of decimal number %d: ",decimalNumber); for(j = i -1 ;j> 0;j--) printf("%d",binaryNumber[j]); return 0; }

12 Use indention for improved clarity Do not put “code” in pseudo code make your pseudo code language independent Don’t write pseudo code for yourself – write it in an unambiguous fashion so that anyone with a reasonable knowledge can understand and implement it Be consistent Prefer formulas over English language descriptions

Advantages  Communication: Flowcharts are better way of communicating the logic of a system to all concerned.  Effective analysis: With the help of flowchart, problem can be analyzed in more effective way.  Proper documentation: Program flowcharts serve as a good program documentation, which is needed for various purposes.  Efficient Coding: The flowcharts act as a guide or blueprint during the systems analysis and program development phase.  Proper Debugging: The flowchart helps in debugging process.  Efficient Program Maintenance: The maintenance of operating program becomes easy with the help of flowchart. It helps the programmer to put efforts more efficiently on that part

Disadvantages  Complex logic: Sometimes, the program logic is quite complicated. In that case, flowchart becomes complex and clumsy.  Alterations and Modifications: If alterations are required the flowchart may require re- drawing completely.  Reproduction: As the flowchart symbols cannot be typed, reproduction of flowchart becomes a problem.  The essentials of what is done can easily be lost in the technical details of how it is done.

Advantages  It can be easily in any word processor.  It can be easily modified as compared to flowchart.  It's implementation is very useful in structured design elements.  It can be written easily.  It can be read and understood easily.  Converting a pseudocode to programming language is very easy as compared with converting a flowchart to programming language.

Disadvantages  It is not visual.  We do not get a picture of the design.  There is no standardized style or format, so one pseudocode may be different from another.  For a beginner, It is more difficult to follow the logic or write pseudocode as compared to flowchart.

 Write an algorithm and draw a flowchart to print all numbers between LOW and HIGH that are divisible by NUMBER  Write an algorithm and draw a flowchart to print the multiplication table for 6's  Write an algorithm and draw a flowchart to arrange N values read from the input in ascending order

 Write an algorithm and draw a flowchart that will find and print the number of vowels in a given set of characters and print there number of occurrences  Write an algorithm and draw a flowchart that will find and print The factorial of NUMBER is FACTORIAL. Test the flowchart for NUMBER=5