Department Vision & Mission

Post on 09-Dec-2021

2 views 0 download

Transcript of Department Vision & Mission

Department of Computer Engineering

1

Vision

Achieve academic excellence through education in computing, to

create intellectual manpower to explore professional, higher

educational and social opportunities.

Mission

To impart learning by educating students with conceptual knowledge

and hands on practices using modern tools, FOSS technologies and

competency skills there by igniting the young minds for innovative

thinking, professional expertise and research.

Department Vision & Mission

Introduction to AlgorithmsKALYANI C. WAGHMARE

AlgorithmAn algorithm is a finite set of instructions that, if followed, accomplishes a particular task.

Algorithm should satisfy following criteria

Input : Zero or more quantities are externally supplied

Output: At least one quantity is produced

Definiteness : Each instruction is clear and unambiguous

Finiteness : If we trace out the instructions of an algorithm, then for all cases, the algorithm terminates after a finite number of steps

Effectiveness: Every instruction must be basic enough to be carried out. It is not enough that each operation be definite; it also must be feasible

Example of AlgorithmAlgorithm to find average of N given numbers

1. Start

2. Enter how many number are there in ‘N’

3. Enter number in variable ‘no’ one by one

4. Add no. to variable ‘sum’

5. Repeat step 3,4 Until counter is less than N

6. Divide sum by N and store result in variable Average

7. Print Average

8. End

Ways to represent Algorithms1) Flowchart

Visual representation of algorithm

2) Pseudocode

Specific tasks written in short, English phrases should not include keywords in any specific computer language.

Algorithm representation using FlowchartFlowchart :

Input / Output

Processing

Condition

Yes

No

Procedure/function

Start/End

Loop

symbol Connector

Symbol Off page Connector

Example - AverageStart

End

Input N

Output Average

Initialize i, Sum =0

Loop i<N

Input number

Sum+=number

Average=Sum/N

yes

No

Pseudocode and its notationsPseudocode :- Pseudocode is an informal way of programming description that does not require any strict programming language syntax or underlying technology considerations.

Advantages of pseudocode –

• Pseudocode is understood by the programmers of all types.

• It enables the programmer to concentrate only on the algorithm part of the code development.

• It cannot be compiled into an executable program.

Example, Java code : if (i < 10) { i++; }

Python code : if(i<10):◦ i=i+1

pseudocode :if i is less than 10, increment i by 1.

Pseudocode notationsBasic Notations :-

START/ END – To start/end the algorithm

INPUT/READ/GET - To take input from user

PRINT/DISPLAY – To display on screen

CALCULATE/DETERMINE – To perform operation

SET/INITIALIZE – To assign some value to variable

INCREMENT/DECREMENT – To increase/decrease value of variable

X ← Y Assign value of y to X

Pseudocode notations continue…Notations for Conditional statements :-

IF condition THEN statements ENDIF

IF condition THEN statements ELSE statements ENDIF

IF condition THEN statements ELSE IF condition THEN statements ENDIF

CASE expr of

Val1:

Val2:

Others

END CASE

Pseudocode notations continue…Notations for looping statements :-

LOOP condition◦ Statements

END LOOP

LOOP ◦ Statements

UNTIL (condition)

Example of PseudocodeAlgorithm to find average of N given numbers

1. START

2. Input ‘N’

3. Initialize i ← 0; sum ← 0;

4. Loop4.1 READ number into no4.2 sum += no

5. Until( i<N)

6. Average ← sum/N

7. PRINT Average

8. END

Example Write Algorithm to Find the largest element in given three element

Draw flowchart to Find the largest element in given three element

Write pseudocode to Find the largest element in given three element

Algorithm1. Start

2. Enter the value of three variables in A, B, C

3. Check if value of A is greater than value of B 3.1 IF true then check A is greater than C

3.1.1 if true print “A is largest”

3.1.2 if false print “C is largest”

3.2 if false check B is greater than C 3.2.1 if true print “ B is largest”

3.2.2 if false print “ C is largest”

4. END

Flowchart Start

Input 3 number in A, B, C

If A>B

Yes No

If A>C

Yes No If B>C

YesNo

Print A is largest Print C is largest Print B is largest

End

PseudocodeSTART

READ A, B, C

IF value of A > B THEN

IF A > C THEN DISPLAY “A is largest”

ELSE

DISPLAY “C is largest”

ENDIF

ELSEIF B > C THEN

DISPLAY “ B is largest”

ELSE

DISPLAY “ C is largest”

ENDIF

ENDIF

AssignmentWrite algorithm, pseudocode and draw flowchart for following

A) Convert given number into Binary and octal

B) Convert given number into Hex

C) Find GCD and LCM of given two numbers

D) Find the equation of line from two given points. Each point has x and y coordinates

E) Find the nth Fibonacci number

F) Find average of first

References1. Horowitz and Sahani, “Fundamentals of Data Structures in C++” , University Press, ISBN 10:0716782928 ISBN 13: 9780716782926.

2. Goodrich, Tamassia, Goldwasser, “Data Structures and Algorithms in C++”, Wiley publication, ISBN-978-81-265-1260-7

3. Yedidyah Langsam, Moshe J Augenstein, AronM Tenenbaum, “Data Structures using C and C++”,Pearson Education, ISBN 81-317-0328-2.

4. A Michael Berman, “Data Structures via C++: Objects by Evolution”, Oxford University Press, ISBN:0-19-510843-4.

5. M. Weiss, “Data Structures and Algorithm Analysis in C++, 2nd edition, Pearson Education, 2002,ISBN-81-7808-670-0.

6. Brassard & Bratley, “Fundamentals of Algorithms”, Prentice Hall India/Pearson Education, ISBN 13-9788120311312