This action might not be possible to undo. Are you sure you want to continue?

Welcome to Scribd! Start your free trial and access books, documents and more.Find out more

)

**Experimental Analysis of Algorithm
**

Deepak Menghani (3rd Year E.C.) Gopesh Sharma (3rd Year E.C.) Poornima College of Engineering, Jaipur (Raj.)

Contents:

Entire PPT is divided into 13 modules:

Introduction ± 30 - 35 sec Definition of an Algorithm ± 1 - 1.2 min Criteria that an Algo must Satisfy ± 1 - 1.4 min Structure of a Standard Algo ± 1 - 1.1 min Rules of Writing an Algo ~ 1 min Various Symbol Meaning ± 30 - 35 sec Different Methods of Writing Algo ± 1 - 1.2 min Examples of Algorithm ± 1 - 1.5 min Space & Time Complexity of an Algo ~ 2 min Needs of Writing an Algo ± 45 - 55 sec Algo-Translater ± 3 - 5 min Algo Simulation & Conclusion References Questions ~ 2 min _________________________________________________

14 January 2012

Total ~ 15 min

2

**Experimental Analysis of Algorithm
**

EAA stands for Experimental Analysis of Algorithm. It is composed of 3 terms: a > EXPERIMENTAL; b > ANALYSIS; & c> ALGORITHM. EXPERIMENTAL means which is based on experiments or whose output is obtained by doing experiments. ANALYSIS refers to detailed examination of elements or structure & ALGORITHM refers to step-wise procedure of doing stepa particular activity. EAA measures the efficiency of an algorithm in terms of time & space complexity that should be minimum. Commonly there are 2 tools which help us to document program logic: Flowcharts and Pseudocode. Pseudocode.

14 January 2012

3

Definition of an Algorithm

According to Brent Daviduck of the Computer Systems Technology program at Red Deer College in Alberta, Canada, ³an algorithm is a Canada, sequence of instructions that are a fundamental part of computing´. Another definition taken from Wikipedia, the free encyclopedia is "an algorithm is a computer program that calculates something³. something³. Thus a standard definition of an algorithm can be stated as: ³An algorithm is a step-wise method / stepprocedure to perform a specific desired task´. task´. The time & spaces it uses are 2 major measures of its efficiency. The complexity of an algorithm is the function which gives the running time or space in terms of the input size.

14 January 2012

4

**Criteria that an algo must satisfy
**

Input - Zero or more quantities are externally supplied. supplied. Output - At least one quantity is produced at output. output. Effectiveness - All the statements of algorithm are clear and terminate only after a finite no. of steps. steps. Low space & time complexity- When complexityimplemented in real life, they should occupy optimal memory space & must save time. time. Datatype- An algorithm cannot contain Datatypedatatype of variables to be used into it. it. For e.g.: we cannot write ³Read int a,b´. Here datatype ³int´ is explicitly mentioned.

5

14 January 2012

**Structure of a Standard Algorithm
**

Structure refers to formatting / design / layout of set of statements that we must follow, while writing an algorithm on paper. It is just similar to syntax / Grammar of a Language. The syntax of every language is different.

For e.g.:

If we are writing a program of printing a message on output screen, the syntax will be different for c, c++ & java.

In c, we can write: printf(³\n PROGRAMMING IN C IS printf(³\ FUN!´); In c++, we can write: cout<<endl<<´PROGRAMMING IN C++ IS FUN!´; In java, we can write: System.out.println(³PROGRAMMING IN JAVA IS FUN!´);

However, there are no set of specific rules for writing an algorithm till date. We can write them according to our convenience in any format & style.

14 January 2012 6

Rules of Writing a Standard algo

First step is always start. start. Stop is used to terminate algorithm. Statements are not case-sensitive. e.g.: Read casee.g.: a & b is similar to READ A & B. Read is a function which is used to read value of variables from user. e.g.: READ A,B,C. e.g.: Write is a function which is used to write message or print value of a variable. e.g. WRITE: WRITING AN ALGO IS FUN! or WRITE C. IS ± THEN is used to check conditions. e.g: IS a > b, THEN: SET max := a, ELSE: SET max := b. Repeat is a function which is used to define a set of statements in a loop body. e.g.: REPEAT steps e.g.: 3-4, WHILE: SUM =/= 0.

7

14 January 2012

Symbol Meaning

In Standard algorithm, meaning of various symbols is:

== =/=

< > <= >=

Equals Not Equals Less than Greater than Less than or equals to Greater than or equals to

In practice, the computer is presented not with a true/false statement, but with a question having a "Yes" or "No" answer, for example if A = 10, B = 20, K = 5, and SALES = 10000, then: Condition (Question) "Answer" Is A == B? No Is B > A? Yes Is K <= 25? Yes Is SALES >= $5000.00? Yes

14 January 2012 8

**Different Methods of Writing Algo
**

METHOD 1:~

STEP 1: START 1: STEP 2: READ MESSAGE 2: STEP 3: WRITE MESSAGE 3: STEP 4: STOP 4:

METHOD 2:~

STEP 0: START 0: STEP 1: GET MESSAGE 1: STEP 2: PRINT MESSAGE 2: STEP 3: RETURN 3:

METHOD 3:~

STEP 1 # Start processing. STEP 2 # Read a message from user. STEP 3 # Save this message in a temporary variable. STEP 4 # Retrieve this message from temporary variable. Retrieve STEP 5 # Print this message on output screen. Print STEP 6 # Terminate process & return. return. And so on«

14 January 2012 9

Examples of Algorithm

Let us Now write algo of some specific programs using standard rules stated above: Example 1: If we are desired to write a program in c programming language whose output is simply addition of 2 variables, then we simply write: main () /*User defined function*/ /*User function*/ { int a,b,c; a,b,c; /*Declaration of variables */ /*Declaration printf(³\ printf(³\n ENTER values of a & b: ³); /*Function to print on dos screen*/ /*Function screen*/ scanf(³%d%d´,&a,&b); scanf(³%d%d´,&a,&b); /* Function to read input from dos screen */ c=a+b /* Statement to assign value of (a + b) into (c) */ printf(³\ printf(³\n ADDITION of a & b is: %d´,c); %d´,c); } Now, let us write algo. of above program algo. STEP 1: START STEP 2: READ A& B [Step corresponding to scanf()] scanf()] STEP 3: SET C := A + B [Step corresponding to c = a + b] b] STEP 4: WRITE C [Step corresponding to printf()] printf()] STEP5: STOP

14 January 2012 10

Example 2: Program to find largest out of 2 numbers. 2: main() { int a,b; printf(³\ printf(³\n ENTER value of a & b: ³); scanf(³%d%d´,&a,&b); scanf(³%d%d´,&a,&b); if (a > b) printf(³\ printf(³\n a is greater than b´); b´); else if (b > a) printf(³\ printf(³\n b is greater than a´); a´); else printf(³\ printf(³\n a & b are equal´); equal´); } Corresponding algorithm can be written as: STEP 1: START 1: STEP 2: READ A& B 2: [Step corresponding to scanf()] scanf()] STEP 3: IS A > B, THEN: WRITE: A IS GREATER B, 3: B, ELSE IF: B > A, THEN: WRITE: B IS GREATER THAN A, THEN: WRITE: A, ELSE: WRITE: A & B ARE EQUAL WRITE: [Step corresponding to if ± else] else] STEP 4: STOP 4:

14 January 2012

11

Space & Time Complexity of an Algorithm

TIME COMPEXITY: This measure is used to estimate COMPEXITY: running time of algorithm in terms of size of input data. SPACE COMPLEXITY: This measure is used to COMPLEXITY: define extra space consumed by the algorithm except input data.

Space & Time Complexity are important parameters of an algorithm in deciding it¶s efficiency. There are 3 popular notations to calculate Space & Time Complexity:

Big Oh Notation (µO¶) ± It measures the upper bound of a function. Omega Notation (Omega) - It measures the lower bound of a function. Theta Notation (Theta) ± It measures in between bound of a function i.e. between upper & lower bound of a function.

14 January 2012

12

**Needs of Writing Algorithm
**

As already discussed, an algorithm refers to that set of statements / instructions, which are designed to perform a specific task. They do not depend on the programming language in which the code is to be implemented. An algo cannot contain datatype of variables. For e.g.: The statements READ INT A,B or WRITE INT A are invalid statements of algo as they explicitly specify the datatype of variables used into it. Before writing a code in some programming language, writing an algorithm is a better practice because: In algo, syntax never matters, thus we can write it in any way matters, we want; It gives information about all the variables to be used in our source code; code; Datatype of all variables can be judged by analyzing the logic used in algorithm; Used for the analyses of logic before writing its code on computer; Everyone can understand algorithm so code-modification codebecomes an easy task; etc.

13

14 January 2012

**ALGOALGO-TRANSLATER Algorithm -> Source Code
**

As a practical approach to validate our proposed design & to apply rules of standard algorithms as created , we are currently working on software module that can decode/convert an algorithm or flowchart into source code of c and c++. The algorithm / flowchart should be written in standard form following rules stated above. User will write algorithm and interpreter will interpret line by line. It will point out any logical or syntactical error & will generate the corresponding source code in a file whose name is stated by user. A module of application can be demonstrated as«

14 January 2012 14

For e.g.: If user write an algo of adding 2 integers in algodecoder IDE: Step1: Step1: Start Step2: Step2: Read a,b Step3: Step3: Set c := a + b Step4: Step4: Write c. Step5: Step5: Stop then corresponding code generated will be: main() { int a,b,c; scanf(³%d%d´,&a,&b); c = a + b; printf(³%d´,c); } in c programming language. void main() { int a,b,c; cin>>endl>>a>>b; c = a + b; cout<<c; } in c++.

14 January 2012

15

Simulation & Conclusions

-> We described about algorithm, their importance in our real life, created rules & decided criteria for writing a standard algorithm. -> An algorithm is the base for computing and it does not depend on programming language in which the code is to be written, operating system in which we are working, environment variables, temporary variables, etc. It is just a skeleton of a program / software module. -> An algorithm cannot contain datatype of variables to be used into it.

14 January 2012

16

References

Wikipedia, Wikipedia, the free encyclopedia. Brent Daviduck of the Computer Systems Technology program at Red Deer College in Alberta, Canada.( http://cst.rdc.ab.ca/) Schaum's Outline of Theory and Problems of Essential Computer Mathematics, by Dr. Seymour Lipshutz, McGraw-Hill, Inc., ISBN: Lipshutz, McGraw0-07-037990-4 Chapter 5 ± Algorithms 07-037990Boolos & Jeffrey 1974, 1999, p. 19. whatis.techtarget.com/definition/0,,sid9_gci21 1545,00.html www.nist.gov/dads/HTML/algorithm www.wisegeek.com/what-is-anwww.wisegeek.com/what-is-an-algorithm.htm

14 January 2012

17

Thank You

For Your Patient Listening

Questions ???

14 January 2012

18

- deSolve
- Manual
- Writing PsuedoCode
- SHORTEST PATH ESTIMATION FOR GRAPH DATA USING A RELATIONAL TECHNIQUE
- Lecture 1 Course Intro
- CVX USer Guide
- oop
- Eee 241 Lecture 11
- aritmethic
- Composition Important
- Vhdl Notes
- spra696a
- 1-Understanding Base Number Systems
- Storage Classes 4
- Functions and Macros
- Byzantine Fault Tolerance in the Distributed Environment Using Markov Chain Technique
- m03L07
- Fortran
- Ansys 11 Multiphysics
- 14__ISSN_1392-1215_A Matlab_Simulink Framework for the Design of Controllers and Observers for Discrete-Event Systems_2
- 4-BookMIT Problem Solutions Jul08941
- Wireless Sensor Networking in Matlab
- Computer Science GATE Que paper 1992
- Scientific American Volume 239 issue 4 1978 [doi 10.1038%2Fscientificamerican1078-104] Edwards, Harold M. -- Fermat's Last Theorem.pdf
- Performance Analysis of Chaotic DS-CDMA with CSK Modulation
- Document 2
- c_ds_lab_txtbook
- Matlab Intro 1

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue listening from where you left off, or restart the preview.

scribd