D IVIDE AND CONQUER STRATEGY, D ATA TYPE, A LGORITHM DESIGN AND PRACTICE. Week 13 Mr.Mohammed Rahmath.

Slides:



Advertisements
Similar presentations
A Level Computing#BristolMet Session Objectives#U2 S2 MUST describe the steps of an algorithm using a program flowchart SHOULD explain the data types and.
Advertisements

Chapter 7 Introduction to Procedures. So far, all programs written in such way that all subtasks are integrated in one single large program. There is.
1 Parallel Parentheses Matching Plus Some Applications.
CS1010 Programming Methodology
 Control structures  Algorithm & flowchart  If statements  While statements.
Definition of a Prime Number
Iteration and Recursion Tonga Institute of Higher Education.
D EVELOPING P ROGRAMS USING ALGORITHMS AND FLOW CHARTS AND VICE VERSA Week 14 Mr.Mohammed Rahmath.
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.
11.3 Function Prototypes A Function Prototype contains the function’s return type, name and parameter list Writing the function prototype is “declaring”
Program Design and Development
Pseudocode and Algorithms
Computer Science 1620 Programming & Problem Solving.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Developing logic (Examples on algorithm and flowchart)
TK3043 Analysis and Design of Algorithms Introduction to Algorithms.
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Unit 1. Sorting and Divide and Conquer. Lecture 1 Introduction to Algorithm and Sorting.
Consecutive Numbers Algebra I.
CS1101: Programming Methodology Aaron Tan.
Introduction to Problem SolvingS1.2.1 Bina © 1998 Liran & Ofir Introduction to Problem Solving Programming in C.
PYTHON PROGRAMMING Week 10 – Wednesday. TERMS – CHAPTER 1 Write down definitions for these terms:  Computation  Computability  Computing  Artificial.
General Programming Introduction to Computing Science and Programming I.
Copyright 1999 by Larry Fuhrer. Pascal Programming Getting Started...
Repetitive Structures BBS514 Structured Programming (Yapısal Programlama)1.
Practice and Evaluation. Practice Develop a java class called: SumCalculator.java which computes a sum of all integer from 1 to 100 and displays the result.
1 INTRODUCTION TO PROBLEM SOLVING AND PROGRAMMING.
Introduction to Pascal The Basics of Program writing.
EXERCISES for ALGORITHMS WRITING
1 Program Planning and Design Important stages before actual program is written.
Program Design. The design process How do you go about writing a program? –It’s like many other things in life Understand the problem to be solved Develop.
Input a number #include using namespace std; int main() { int num; cout num; return 0; }
Cosc175/operators1 Algorithms computer as the tool process – algorithm –Arithmetic: addition,subtraction,multiplication,division –Save information for.
ALGORITHMS.
1 10/3/05CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
© Janice Regan, CMPT 128, February CMPT 128: Introduction to Computing Science for Engineering Students Recursion.
Sorting. Sorting Sorting is important! Things that would be much more difficult without sorting: –finding a telephone number –looking up a word in the.
Introduction to design and analysis algorithm
Problem, Problem Solving, Algorithm & Flow Charts –Part 1 Presented By Manesh T Course:101 CS 101CS Manesh T1.
Recitation 8 Programming for Engineers in Python.
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,
Think First, Code Second Understand the problem Work out step by step procedure for solving the problem (algorithm) top down design and stepwise refinement.
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
COMP Loop Statements Yi Hong May 21, 2015.
CMSC 104, Section 301, Fall Lecture 18, 11/11/02 Functions, Part 1 of 3 Topics Using Predefined Functions Programmer-Defined Functions Using Input.
Program Program is a collection of instructions that will perform some task.
Program Development and Design Using C++, Third Edition
Recursion Chapter 7 Copyright ©2012 by Pearson Education, Inc. All rights reserved.
Selection Using IF THEN ELSE CASE Introducing Loops.
CSC 143 P 1 CSC 143 Recursion [Chapter 5]. CSC 143 P 2 Recursion  A recursive definition is one which is defined in terms of itself  Example:  Compound.
What will each of the following lines print? System.out.println("number" ); number645 System.out.println("number" + (6 + 4)+ 5); number105 System.out.println(6.
15.1 More About High-Level Programming Languages Syntax and Semantics Each programming language contains its own rules for both syntax and semantics. Syntax.
Introduction to Algorithms: Divide-n-Conquer Algorithms
Algorithms IV Top-Down Design.
2.3 Solving Multi-Step Equations
Topic 6 Recursion.
Problem , Problem Solving, Algorithm & Flow Charts –Part 1
Consecutive Numbers Algebra I.
Unit 1. Sorting and Divide and Conquer
Topic:- ALGORITHM Incharge Faculty – Lokesh Sir.
Functions in C++ Eric Roberts CS 106B January 7, 2015.
3rd prep. – 2nd Term MOE Book Questions.
Siti Nurbaya Ismail Senior Lecturer
Recursion "To understand recursion, one must first understand recursion." -Stephen Hawking.
Programming Funamental slides
Chapter 5: Control Structure
Divide and Conquer Algorithms Part I
Algorithms computer as the tool process – algorithm
COMPUTING.
Presentation transcript:

D IVIDE AND CONQUER STRATEGY, D ATA TYPE, A LGORITHM DESIGN AND PRACTICE. Week 13 Mr.Mohammed Rahmath

D IVIDE AND CONQUER STRATEGY A divide and conquer algorithm works by recursively breaking down a problem into two or more sub-problems of the same (or related) type, until these become simple enough to be solved directly. The solutions to the sub-problems are then combined to give a solution to the original problem. Mr.Mohammed Rahmath

A DVANTAGES OF DIVIDE AND CONQUER STRATEGY Solving difficult problems Algorithm efficiency Parallelism Memory access Roundoff control Mr.Mohammed Rahmath

D ATA TYPE Data type is define as the type of data. Example: integers, Boolean, characters, floating- point numbers, alphanumeric strings… Mr.Mohammed Rahmath

A LGORITHM Definition : an algorithm is a step-by-step procedure for calculations. Algorithms are used for calculation, data processing, and automated reasoning. Mr.Mohammed Rahmath

S TEPS IN DEVELOPMENT OF A LGORITHMS 1. Problem definition 2. Development of a modal 3. Specification of Algorithm 4. Designing an Algorithm 5. Checking the correctness of Algorithm 6. Analysis of Algorithm 7. Implementation of Algorithm 8. Program testing 9. Documentation Preparation Mr.Mohammed Rahmath

E XAMPLE Q) Write a algorithm to find out number is odd or even? step 1 : start step 2 : input number step 3 : rem=number mod 2 step 4 : if rem=0 then print "number even" else print "number odd" endif step 5 : stop Mr.Mohammed Rahmath

Q) Write an algorithm to add two numbers entered by user. Step 1: Start Step 2: Declare variables num1, num2 and sum. Step 3: Read values num1 and num2. Step 4: Add num1 and num2 and assign the result to sum. sum←num1+num2 Step 5: Display sum Step 6: Stop Mr.Mohammed Rahmath

Q) Write an algorithm to check whether a number entered by user is prime or not. Step 1: Start Step 2: Declare variables n,i,flag. Step 3: Initialize variables flag←1 i←2 Step 4: Read n from user. Step 5: Repeat the steps until i<(n/2) 5.1 If remainder of n÷i equals 0 flag←0 Go to step i←i+1 Step 6: If flag=0 Display n is not prime else Display n is prime Step 7: Stop Mr.Mohammed Rahmath

Q) Write an algorithm to find the largest among three different numbers entered by user. Step 1: Start Step 2: Declare variables a,b and c. Step 3: Read variables a,b and c. Step 4: If a>b If a>c Display a is the largest number. Else Display c is the largest number. Else If b>c Display b is the largest number. Else Display c is the greatest number. Step 5: Stop Mr.Mohammed Rahmath

S ESSION 13 E ND Mr.Mohammed Rahmath