Topic:- ALGORITHM Incharge Faculty – Lokesh Sir.

Slides:



Advertisements
Similar presentations
PROBLEM SOLVING TECHNIQUES
Advertisements

CHAPTER 2 GC101 Program’s algorithm 1. COMMUNICATING WITH A COMPUTER  Programming languages bridge the gap between human thought processes and computer.
Algorithms + L. Grewe.
Algorithm –History Muhammad ibn Musa Al-Khwarizmi www -groups.dcs.st-andrews.ac.uk/~history/Mathematicians/Al- Khwarizmi.html Book on arithmetic:
D IVIDE AND CONQUER STRATEGY, D ATA TYPE, A LGORITHM DESIGN AND PRACTICE. Week 13 Mr.Mohammed Rahmath.
Lesson 19 Recursion CS1 -- John Cole1. Recursion 1. (n) The act of cursing again. 2. see recursion 3. The concept of functions which can call themselves.
What is an algorithm? Informally: An Algorithm is a step by step method for solving a problem. It’s purpose is to break a larger task down so that each.
Lecture Notes 1/21/04 Program Design & Intro to Algorithms.
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
J. Michael Moore Recursion CSCE 110 From James Tam’s material.
TK3043 Analysis and Design of Algorithms Introduction to Algorithms.
BPC.1 Basic Programming Concepts
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
CS212: DATASTRUCTURES Lecture 3: Recursion 1. Lecture Contents 2  The Concept of Recursion  Why recursion?  Factorial – A case study  Content of a.
Fundamentals of C programming
ALGORITHMS AND FLOWCHARTS
Introduction Dr. Ying Lu RAIK 283: Data Structures & Algorithms.
COMP An Introduction to Computer Programming : University of the West Indies COMP6015 An Introduction to Computer Programming Lecture 02.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 19: Recursion.
A Review of Recursion Dr. Jicheng Fu Department of Computer Science University of Central Oklahoma.
1 R. Johnsonbaugh, Discrete Mathematics Chapter 4 Algorithms.
Recursion. Basic problem solving technique is to divide a problem into smaller sub problems These sub problems may also be divided into smaller sub problems.
Recursion.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
CIS 068 Welcome to CIS 068 ! Stacks and Recursion.
Recursion Textbook chapter Recursive Function Call a recursive call is a function call in which the called function is the same as the one making.
Computer Science Department Data Structure & Algorithms Lecture 8 Recursion.
CS212: DATASTRUCTURES Lecture 3: Recursion 1. Lecture Contents 2  The Concept of Recursion  Why recursion?  Factorial – A case study  Content of a.
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Flowcharts.
Introduction to Algorithms By Mr. Venkatadri. M. Two Phases of Programming A typical programming task can be divided into two phases: Problem solving.
CPS120 Introduction to Computer Programming The Programming Process.
Chapter 2 Problem Solving On A Computer 2.1 Problem Solving Steps Solving a problem on a computer requires steps similar to those followed when solving.
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.
Data Structures R e c u r s i o n. Recursive Thinking Recursion is a problem-solving approach that can be used to generate simple solutions to certain.
Recursive Algorithms &
1 Topics Recursion sections 8.1 – Recursion A recursively defined sequence –First, certain initial values are specified –Later terms of the sequence.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
1 Programming Tools Flowcharts Pseudocode Hierarchy Chart Direction of Numbered NYC Streets Algorithm Class Average Algorithm.
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Recursion.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
WHAT IS THIS? Clue…it’s a drink SIMPLE SEQUENCE CONTROL STRUCTURE Introduction A computer is an extremely powerful, fast machine. In less than a second,
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
Algorithms and Pseudocode
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.
Why Repetition? Read 8 real numbers and compute their average REAL X1, X2, X3, X4, X5, X6, X7, X8 REAL SUM, AVG READ *, X1, X2, X3, X4, X5, X6, X7, X8.
Program Program is a collection of instructions that will perform some task.
| MSC 8102:PROGRAMMING CONCEPTS By Vincent Omwenga, PhD. 1.
Chapter 19: Recursion.
Programming Languages
Problem , Problem Solving, Algorithm & Flow Charts –Part 1
2008/09/22: Lecture 6 CMSC 104, Section 0101 John Y. Park
ALGORITHMS AND FLOWCHARTS
Lecture 2 Introduction to Programming
CSE322 Recursive and Recursively enumerable sets
ALGORITHMS AND FLOWCHARTS
Written Midterm Solutions
Unit# 9: Computer Program Development
ALGORITHMS AND FLOWCHARTS
Coding Concepts (Basics)
Introduction to Algorithms and Programming
Computer Programming.
Problem Solving Skill Area 305.1
Introduction to Algorithms - 1
The structure of programming
Basic Concepts of Algorithm
Algorithm Course Algorithms Lecture 3 Sorting Algorithm-1
REPETITION Why Repetition?
Presentation transcript:

Topic:- ALGORITHM Incharge Faculty – Lokesh Sir. Name of students – Jerin Varghese(T0114ME201), Vivek Vasava(T0114ME158).

ALGORITHM Review

ALGORITHM Definition: - An algorithm can be defined as a finite sequence of well defined steps or operations for solving a problem in systematic manner. These are rules for solving any problems in proper manner. Instruction are written in the natural language. It is also called step by step solution.

ALGORITHM There are various types of algorithm techniques, according to types of problems: - Divide and Conquer. Greedy method. Branch and Bound. Recursion. Effectiveness. An algorithm can be defined as a finite sequence of well defined steps or operations for solving a problem in systematic manner. These are rules for solving any problems in proper manner. Instruction are written in the natural language. It is also called step by step solution.

ALGORITHM Divide and conquer: - Greedy method: - The divide and conquer technique is used to solve complex problems easily. Complex problems are decomposed into several step, which make problem easy to solve. Greedy method: - This method is used to solve optimization problem. With several possible solution one best solution is selected With help of this method.

ALGORITHM Branch and bound: - Recursion: - when there are several statements or certain part of logic repeated this type of concept is used. A branch and bound algorithm computes a number(bound) at a node to determine whether the node is promised. Recursion: - When procedure calls itself is called recursion.

ALGORITHM Effectiveness: - All operations can be carried out in predefined time and sequence.

ALGORITHM Example 1: - Write an algorithm to find out sum of two numbers. Step 1 : input two numbers : a, b Step 2 : calculate sum = a + b Step 3 : Print “total = “ , sum Step 4 : stop

ALGORITHM Example 2: - Write an algorithm to find average of three numbers. Step 1 : input three numbers : a, b, c Step 2 : calculate sum = a + b + c Step 3 : avg = sum / 3 Step 4 : print “average = “ , avg Step 5 : stop

ALGORITHM Example 3: - Write an algorithm to find whether given number is positive or negative. Step 1 : input number : num Step 2 : check if num < 0 then go to step 5 Step 3 : print “Positive “ Step 4 : stop Step 5 : print “Negative “ Step 6 : stop

ALGORITHM Example 4: - Write an algorithm to find out minimum number from three numbers. Step 1 : input three numbers : a, b, c Step 2 : if a < b then go to next step else go to step 8 Step 3 : if a < c then go to next step else go to step 6 Step 4 : print “Minimum = “ , a Step 5 : stop Step 6 : print “Minimum = “ , c Step 7 : stop Step 8 : if b < c then go to next step else go to step 11 Step 9 : print “Minimum = “ , b Step 10 : stop Step 11 : print “Minimum = “, c Step 12 : stop

ALGORITHM Example 5: - Write an algorithm to find factorial of given number. Step 1 : input number : num Step 2 : i = 1 Step 3 : f = 1 Step 4 : repeat from step 4 to step 6 until I <= num Step 5 : f = f * i Step 6 : i = i + 1 Step 7 : print “Factorial = “ , f Step 8 : stop

ALGORITHM Example 6: - Write an algorithm to reverse given number. Step 1 : input number : num Step 2 : sum = 0 Step 3 : repeat from step 3 to step 6 until num > 0 Step 4 : calculate r = num % 10 Step 5 : calculate sum = sum * 10 + r Step 6 : calculate num = num / 10 Step 7 : print “Reverse number = “ , sum Step 8 : stop

ALGORITHM Example 7: - Write an algorithm to solve following series 1! + 2! + 3! + …… + n!. Step 1 : input number : num Step 2 : f = 1 Step 3 : sum = 0 Step 4 : i = 1 Step 5 : repeat from step 5 to step 8 until i <= num Step 6 : f = f * i Step 7 : sum = sum + f Step 8 : i = i + 1 Step 9 : print “Sum = “ , sum Step 10 : stop

ALGORITHM Example 8: - Write an algorithm to find if the given number is Armstrong or not. Step 1 : input number : num Step 2 : sum = 0, temp = num Step 3 : repeat from step 3 to step 6 until num > 0 Step 4 : calculate r = num / 10 Step 5 : calculate sum = sum + r * r * r Step 6 : calculate num = num % 10 Step 7 : if temp = sum then next step else go to step 9 Step 8 : print temp, “Is not Armstrong number” Step 9 : stop Step 10 : print temp, “Is not Armstrong number” Step 11 : stop

ALGORITHM Example 9: - Write an algorithm to store sum of 10 different numbers. Step 1 : sum = 0 Step 2 : i = 1 Step 3 : repeat from step 3 to step 6 until i <= 10 Step 4 : read num Step 5 : sum = sum + num Step 6 : i = i + 1 Step 7 : print “Total = “ , sum Step 8 : stop

ALGORITHM Example 10: - Write an algorithm to find whether given number is prime or not. Step 1 : read num Step 2 : i = 2 Step 3 : repeat from step 3 to step 6 until i < num Step 4 : if num % i = 0 then go to next step else go to step 7 Step 5 : print num “Is not prime “ Step 6 : stop Step 7 : i = i + 1 Step 8 : print num, “Is prime “ Step 9 : stop

THANK YOU