CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Design and Analysis of Algorithms.

Slides:



Advertisements
Similar presentations
Testing Relational Database
Advertisements

Analysis of Computer Algorithms
1 ICS102: Introduction To Computing King Fahd University of Petroleum & Minerals College of Computer Science & Engineering Information & Computer Science.
Chapter 1 An Overview of Computers and Programming Languages.
ICS103 Programming in C Lecture 1: Overview of Computers & Programming
Design & Analysis of Algoritms
Computer science is a field of study that deals with solving a variety of problems by using computers. To solve a given problem by using computers, you.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
CSE 830: Design and Theory of Algorithms
What is an algorithm? An algorithm is a sequence of unambiguous instructions for solving a problem, i.e., for obtaining a required output for any legitimate.
Computer Science 1620 Programming & Problem Solving.
Software Testing. “Software and Cathedrals are much the same: First we build them, then we pray!!!” -Sam Redwine, Jr.
Chapter 1 Program Design
UNIVERSITY OF SOUTH CAROLINA Department of Computer Science and Engineering Design and Analysis of Algorithms - Chapter 11 Algorithm An algorithm is a.
TK3043 Analysis and Design of Algorithms Introduction to Algorithms.
Design & Analysis of Algorithms Introduction. Introduction Algorithms are the ideas behind computer programs. An algorithm is the thing which stays the.
Data Structures and Programming.  John Edgar2.
UNIT 21 Software Engineering.
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
Introduction to Systems Analysis and Design Trisha Cummings.
CS223 Algorithms D-Term 2013 Instructor: Mohamed Eltabakh WPI, CS Introduction Slide 1.
1 Shawlands Academy Higher Computing Software Development Unit.
Chapter 8: Systems analysis and design
1 UNIT 20 Software Engineering Lecturer: Ghadah Aldehim.
CSC-115 Introduction to Computer Programming
Programming Lifecycle
TMF1013 : Introduction To Computing Lecture 1 : Fundamental of Computer ComputerFoudamentals.
CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Design and Analysis of Algorithms.
Introduction Algorithms and Conventions The design and analysis of algorithms is the core subject matter of Computer Science. Given a problem, we want.
Introduction to Software Testing. Types of Software Testing Unit Testing Strategies – Equivalence Class Testing – Boundary Value Testing – Output Testing.
Chapter 1 Program design Objectives To describe the steps in the program development process To introduce the current program design methodology To introduce.
Introduction to Problem Solving. Steps in Programming A Very Simplified Picture –Problem Definition & Analysis – High Level Strategy for a solution –Arriving.
1 Ch. 1: Software Development (Read) 5 Phases of Software Life Cycle: Problem Analysis and Specification Design Implementation (Coding) Testing, Execution.
The Software Development Process
2. Program Development Intro Programming in C++ Computer Science Dept Va Tech August 2001 ©2001 Barnette ND & McQuain WD 1 Top-Down Design:A solution method.
Algorithms 1.Notion of an algorithm 2.Properties of an algorithm 3.The GCD algorithm 4.Correctness of the GCD algorithm 5.Termination of the GCD algorithm.
Data Structures and Algorithms Dr. Tehseen Zia Assistant Professor Dept. Computer Science and IT University of Sargodha Lecture 1.
Software Development Problem Analysis and Specification Design Implementation (Coding) Testing, Execution and Debugging Maintenance.
UNIT-I INTRODUCTION ANALYSIS AND DESIGN OF ALGORITHMS CHAPTER 1:
Software Engineering1  Verification: The software should conform to its specification  Validation: The software should do what the user really requires.
CS404 Design and Analysis of Algorithms BBy DDr. M V S Peri Sastry BB.E, PhD(BITS-Pilani)
How Are Computers Programmed? CPS120: Introduction to Computer Science Lecture 5.
Introduction to design and analysis algorithm
1 The Software Development Process ► Systems analysis ► Systems design ► Implementation ► Testing ► Documentation ► Evaluation ► Maintenance.
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,
Onlinedeeneislam.blogspot.com1 Design and Analysis of Algorithms Slide # 1 Download From
Lecture #1: Introduction to Algorithms and Problem Solving Dr. Hmood Al-Dossari King Saud University Department of Computer Science 6 February 2012.
BITS Pilani Pilani Campus Data Structure and Algorithms Design Dr. Maheswari Karthikeyan Lecture1.
Program Design. Simple Program Design, Fourth Edition Chapter 1 2 Objectives In this chapter you will be able to: Describe the steps in the program development.
INTRODUCTION TO COMPUTER PROGRAMMING(IT-303) Basics.
Algorithms and Problem Solving. Learn about problem solving skills Explore the algorithmic approach for problem solving Learn about algorithm development.
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.
1 Introduction to design and analysis algorithm. 2.
Some of the utilities associated with the development of programs. These program development tools allow users to write and construct programs that the.
Victoria Ibarra Mat:  Generally, Computer hardware is divided into four main functional areas. These are:  Input devices Input devices  Output.
MANAGEMENT INFORMATION SYSTEM
Maitrayee Mukerji. INPUT MEMORY PROCESS OUTPUT DATA INFO.
Algorithms and Problem Solving
INTRODUCTION TO PROBLEM SOLVING
TK3043 Analysis and Design of Algorithms
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Lecture 2 of Computer Science II
Testing UW CSE 160 Spring 2018.
Unit# 9: Computer Program Development
Baisc Of Software Testing
Algorithms and Problem Solving
Chapter 1 Introduction Copyright © 2007 Pearson Addison-Wesley. All rights reserved.
Presentation transcript:

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Design and Analysis of Algorithms Khawaja Mohiuddin Assistant Professor, Department of Computer Sciences Bahria University, Karachi Campus, Contact: Lecture # 2 – Algorithm Basics

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 2  Basic Concerns  Computer programming is both an art and science  Elegance and beauty of expression on one hand  Accuracy, correctness, reliability and efficiency on the other hand  These concerns arise trying to balance the needs of two classes of people  The Programmers: who would like to be elegant and expressive, while delivering correctness and efficiency  The Users: who would like accuracy, reliability, correctness and efficiency in a program  In general, both are concerned with a good solution to a problem  A good solution is economical in the use of computing and human resources

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 3  What is Algorithm? What do you think?

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 4  Algorithm  The Concise Oxford Dictionary defines Algorithm (also “Algorism”) as: a process or a set of rules used for calculation or problem solving, especially with a computer  The word algorithm is derived by a distortion of the name Al-Khuwarizmi, a Persian Mathematician of 9 th Century A.D.  In Computer Science, algorithm has a special significance to mean “a precise method usable by a computer for the solution of a problem”  An algorithm is composed of a finite number of steps, each of which may require one or more operations. These operations must be unambiguous. This implies that each of these operations must be definite, clearly specifying what is meant to be done  All steps in the algorithm should be effective, that is, they should produce the desired result in a finite time frame  The algorithm should terminate after a finite number of operations. If the algorithm does not terminate in certain time limit, we do have a serious problem.  Thus, an algorithm should be definite, effective and finite

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 5  Program  A program is an expression of algorithm in a programming language e.g. C, C++, Java, FORTRAN etc.  Five Distinct Areas in the Study of Algorithms  To devise an algorithm: This is an activity where human intelligence is definitely required; some of the strategies used have a general applicability like dynamic programming, divide-and conquer, back-tracking, and so on.  To express an algorithm: An algorithm can be expressed in various ways: flow-chart, pseudo-code, program, and the like. Out of these only the program in certain programming languages are acceptable to a computer.

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 6  Five Distinct Areas in the Study of Algorithms  To validate an algorithm: This means that a program satisfies its precise specifications. This involves proving the correctness of an algorithm. Once an algorithm is shown to be correct, only then should the program coding begin. The program also has to be verified by testing, profiling and so on.  To analyze an algorithm: This field is called analysis of algorithms. It is concerned with the amount of computer time and storage that is required by the algorithm. This study allows us to compare valid algorithms for efficiency.  To test a program: Testing a program consists of two parts – debugging and profiling. Debugging can only point to the presence of errors and never their absence. Profiling is a process of executing a correctly working program with the appropriate data sets, and measuring the time and memory space it takes to execute various parts of the program.

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 7  Algorithm and Data Structure  An algorithm is a recipe for performing a certain task  A data structure is a way of arranging data to make solving a particular problem easier  A data structure could be a way of arranging values in an array, a linked list that connects items in a certain pattern, a tree, a graph, a network etc.  An algorithm does not necessarily need a data structure. For example, many of the numeric algorithms do not use data structures  On the other hand, there is a need to use some sort of algorithm to build the data structure.

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 8  Qualitative Aspects of Good Solutions (Algorithms)  They are simple yet powerful and general solutions  They can be easily understood by others which means that the implementation is clear and concise in the use of without being tricky  They can be easily modified if necessary  They give correct results for all clearly specified cases, including extreme cases  They are economical in the use of computer time, computer storage, and peripherals  They are properly documented, so that they can be used by others for their own applications  They are not dependent on any particular computer hardware or operating system on which they are run or implemented – system independence (portability)  They can be used as sub-procedures for other problems and applications  They are pleasing and satisfying to their designer – no patch-work solution

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 9  Quantitative Aspects of Good Solutions (Algorithms)  Quantitative measures are valuable as they provide a way of directly predicting and evaluating the performance of a good solution and comparing the relative performance of two or more solutions  More efficient solutions result in saving in computations, which results in saving in computer resource usage which in turn saves time and money  Algorithm Features  A good algorithm must have three features: correctness, maintainability and efficiency

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 10  Correctness  A program works correctly, outputting the expected behaviour and results in the complete range of data that is required to handle  One cannot demonstrate the correctness of the program by simply taking each of the possible input data, feeding it to the program, and showing that the result is correct.  Example: A boy sent to the market to buy a match box and asked to check the box for any moisture before buying it. The boy went on lighting one match-stick after another, till all were burnt. When asked why he did so, he replied “But then how can I be sure if the other matches will light?” Unfortunately, the computer programmers are in the same situation. How can they be sure that the program is correct without exhaustive testing?

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 11  Correctness  He could have argued that if the box had absorbed moisture, there was a good probability that all the match-sticks would be equally moist. So if he had tested any one of them, it should tell him about the whole box  Thus, he could have used limited testing plus proof instead of exhaustive testing  Efficiency  A program should be efficient, both in terms of execution time and the amount of resources like main memory it uses  However, the correctness requirement is fundamental, what will one do with a program that is very fast but does not give correct results?

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 12  Maintainability  If an algorithm isn’t maintainable, it is dangerous to use in a program. If an algorithm is simple, intuitive, and elegant, one can be confident that it is producing correct results, and one can fix it if it does not.  If the algorithm is intricate, confusing, and convoluted, one may have a lot of trouble implementing it, and one will have even more trouble fixing it if a bug arises.  If it is hard to understand, how can one know if it is producing correct results?

CSC-305 Design and Analysis of AlgorithmsBS(CS) -6 Fall-2014 Algorithm Basics 13  Pseudo-code  Pseudo-code is text that is a lot like a programming language but that is not really a programming language  The idea is to give the structure and details that would need to implement the algorithm in code without tying the algorithm to a particular programming language  The following snippet shows an example of pseudo-code for an algorithm that calculates the greatest common divisor (GCD) of two integers:  // Find the greatest common divisor of a and b. // GCD (a, b) = GCD(b, a Mod b). Integer: Gcd (Integer: a, Integer: b) While (b != 0) // Calculate the remainder. Integer: remainder = a Mod b // Calculate GCD (b, remainder). a = b b = remainder End While Return a // GCD (a, 0) is a. End Gcd