672 views

Uploaded by Kiran Kumar

- exam1-sol
- Search Sort
- Ds Lab Manual
- analysis and design of algorithms1.doc
- Study and Practice of Yoga Volume-I
- Cse-IV-Design and Analysis of Algorithms [10cs43]-Notes
- 56009
- FUNDAMENTALS
- Comprehensive Guide to Campussing
- 11.05.08
- CSC 3110_Study Guide
- Google Prep Session
- A Few Improvements for Selection Sort Algorithm
- The Common Comlexities Handout
- EC-101ATUT_6_AU_2011
- daa
- Automatic Test Case Generation for Structural Testing Using Negative Selection Algorithm
- Q2
- 72024082-Arrays
- Scimakelatex.6806.Biblos.pok.Vup.wenn.Gggggg

You are on page 1of 7

solving a computational problem,

Problem i.e., for obtaining a required

output for any legitimatemmeem

input in a finite amount of time.

mnmn

mmmm

m

algorithm

m

methods

for solving the same problem: Computing th greatest common

divisor.

m and n, denoted by gcd(m,n), is defined as the largest integer that

divides both m and n evenly.

First try -- Euclid’s algorithm: gcd(m, n) = gcd(n, m mod n)

equality.

gcd(m,n) = gcd(n,m mod n)

gcd(m, n): the largest integer that divides both m and n.

First try -- Euclid’s algorithm: gcd(m, n) = gcd(n, m mod n)

otherwise, proceed to Step 2.

Step2: Divide m by n and assign the value of the remainder to r.

Step 3: Assign the value of n to m and the value of r to n. Go to Step

1.

Algorithm Euclid(m, n)

//Computes gcd(m, n) by Euclid’s algorithm

//Input: Two nonnegative, not-both-zero integers m and n

//Output: Greatest common divisor of m and n

while n ‡ 0 do

r ß m mod n

mßn

nßr

return m

Step2: Divide m by t. If the remainder of this division is 0,

go to Step3;otherwise, go to Step 4.

Step3: Divide n by t. If the remainder of this division is 0,

return the value of t as the answer and stop; otherwise,

proceed to Step4.

Step4: Decrease the value of t by 1. Go to Step2.

Middle-school procedure

Step1: Find the prime factors of m.

Step2: Find the prime factors of n.

Step3: Identify all the common factors in the two prime

expansions found in Step1 and Step2. (If p is a common

factor occurring Pm and Pn times in m and n, respectively,

it should be repeated in min{Pm, Pn} times.)

Step4: Compute the product of all the common factors and

return it as the gcd of the numbers given.

60 = 2 . 2 . 3 . 5

24 = 2 . 2 . 2 . 3

gcd(60,24) = 2 . 2 . 3 = 12

The same algorithm can be represented in several different

ways. (different pseudocodes)

There might exists more than one algorithm for a certain

problem.

Algorithms for the same problem can be based on very different

ideas and can solve the problem with dramatically different

speeds.

Reading the problems description carefully, Asking

questions, do a few examples by hand, think about special

cases, etc.

Deciding on

Exact vs. approximate problem solving

Appropriate data structure

Design an algorithm

Proving correctness

Analyzing an algorithm

Time efficiency : how fast the algorithm runs

Space efficiency: how much extra memory the algorithm

needs.

Simplicity and generality

Coding an algorithm

An input to an algorithm specifies an instance of the problem the

algorithms solves. It is very important to specify exactly te range of

instances the algorithms needs to handle. Failure to do this, the

algorithm may work correctly for a majority of inout but crash on some

“boundary” value. A correct algorithm is not one that works most of

the time but one that works correctly for all legitimate inputs.

Once having understood a problem, one must ascertain the capabilities

of the computational device the algorithm is intended for. In the case

of random-access memory (RAM), its central assumption is that

instructions are executed one after another, one operation at a time.

Accordingly algorithms are designed to be executed on such machines

are called sequential algorithms.

Some new computers can execute operations concurrently; i.e. in

parallel. Algorithms that take advantage of this capability are called

parallel algorithms

The next principal decision is to choose between solving the problem

exactly or solving it appropriately. The former case algorithm is called

exact algorithm latter case, an algorithm is called appropriate

algorithm.

In the new world of object oriented programming, data structures

remain crucially important for both design and analysis of algorithms.

Algorithms + Data structures = Programs

What is an algorithm design technique?

An algorithm design technique is a general approach to solving

problems algorithmically that is applicable to a variety of problems for

different areas of computing.

Once having designed an algorithm, you need to specify it in some

fashion. Using natural language is obviously difficult.

A pseudocode is a mixture of a natural language and programming

language like constructs. A pseudocode is usually more precise than an

natural language.

Computer scientists never have agreed on a single form pf

pseudocode.

correctness. That is you have to prove that the algorithm yields a

required result for every legitimate input in a finite amount of time. For

algorithms, a proof of correctness is to use mathematical induction

because an algorithm’s iteration provide a natural sequence of steps

needed for such proofs.

The notion of correctness for approximation algorithms is less

straightforward than it is for exact algorithms. Errors for approximation

algorithms should not exceed a predefined limit.

Analyzing an Algorithm:

kinds of algorithm efficiency:

• Time efficiency: indicates how fast the algorithm runs.

• Space efficiency: indicates how much extra memory the

algorithm needs.

important algorithm characteristic. Because simple algorithms are

easier to understand and easier to program. Resulting programs

usually contain fewer bugs. Simper algorithms are also more efficient

than more complicated alternatives.

issues here:

• Generality of the problem the algorithm solves – it is easier to

design an algorithm for a more general problem. But there are

situations where designing a more general algorithm is

unnecessary or difficult or even impossible.

• The range of inputs it accepts – your main concern should be

designing an algorithm that can handle a range of inputs that is

natural for the problem at hand.

Coding an Algorithm:

Most algorithms are ultimately implemented as computer programs.

Transition of algorithm to a program must be done carefully. Validity of

the computer program is established by testing. Testing of computer

programs is an art rather than science.

Sorting

Searching

String processing

Graph problems

Combination problems

Geometric problems

Numerical problems

Sorting:

Input: A sequence of n numbers <a1, a2, …, an>

Output: A reordering <a´1, a´2, …, a´n> of the input

sequence such that a´1≤ a´2 ≤ … ≤ a´n.

Sorting can be done to sort list of numbers, characters from

an alphabet, character strings and records maintained by

schools about students and libraries about books and

companies about their employees.

Why sorting?

Help searching

Algorithms often use sorting as a key subroutine.

Sorting key

A specially chosen piece of information used to guide sorting.

I.e., sort student records by names.

Selection sort

Bubble sort

Insertion sort

Merge sort

Heap sort

comparisons.

Two properties

Stability: A sorting algorithm is called stable if it preserves

the relative order of any two equal elements in its input.

In place : A sorting algorithm is in place if it does not

require extra memory, except, possibly for a few memory

units.

Searching:

search key, in a given set.

Examples of searching algorithms

Sequential searching

Binary searching

String

comprises of Text strings: letters, numbers, and special characters. Bit

strings comprises of zeros and ones.

String matching: searching for a given word/pattern in a text.

Graph Problems

A graph is a collection of points called vertices, some of which are

connected by line segments called edges. Graphs can be used for:

• Modeling WWW

• transportation

• communication networks

• Project scheduling …

Shortest-path algorithms

Topological sorting

cities that visits every city exactly once.

The graph coloring problem – assigns the smallest number of colors to

vertices of a graph so that no two adjacent vertices are the same color.

Combinational Problems:

The traveling saleman problems and the graph coloring problems are

examples of combination problems. These problems ask to find a

combinatorial object – such as permutation, a combination, or a subset

– that satisfies certain constraints and has some desired property.

Geometic Problems:

lines and polygons. Ancient greeks have invented procedures for

solving problems of constructing simple geometric shapes – triangles,

circles etc.

Numerical Problems:

that involve mathematical objects of continuous nature: solving

equations and systems of equations, computing definite integrals,

evaluating functions.

- exam1-solUploaded bytmp11590
- Search SortUploaded byPreety Barman
- Ds Lab ManualUploaded bycore9418
- analysis and design of algorithms1.docUploaded byHarendra Kumar
- Study and Practice of Yoga Volume-IUploaded byHarshitShukla
- Cse-IV-Design and Analysis of Algorithms [10cs43]-NotesUploaded bySampreeth03
- 56009Uploaded byfaizu35
- FUNDAMENTALSUploaded bysankarwinning
- Comprehensive Guide to CampussingUploaded byDebroop Sengupta
- 11.05.08Uploaded byarunsmile
- CSC 3110_Study GuideUploaded byanon_29869256
- Google Prep SessionUploaded bykxzaab
- A Few Improvements for Selection Sort AlgorithmUploaded byATS
- The Common Comlexities HandoutUploaded byNorbert
- EC-101ATUT_6_AU_2011Uploaded byarchit.arrish
- daaUploaded bymalli009
- Automatic Test Case Generation for Structural Testing Using Negative Selection AlgorithmUploaded byHamaad Rafique
- Q2Uploaded bysimrang31
- 72024082-ArraysUploaded bySai Krishna Velicheti
- Scimakelatex.6806.Biblos.pok.Vup.wenn.GgggggUploaded byAnnamaria Lanciani
- Convent of Jesus and MaryUploaded byArup Sarkar
- Me So to Connect With ThouUploaded bysfofoby
- Algorithm AnalysisUploaded bynetisheth
- 6-2Uploaded byDhanraj Kolkur
- QuestionPack.Comp1.DesignDryRunUploaded byShakila Shaki
- venkatesanUploaded byPrabhu Jaysus
- Presentation 11Uploaded byAnam Shoaib
- Complexity (1)Uploaded byUsama Chaudhary
- Bitonic SortUploaded byPreetesh Pathak
- 8. Approach to Design.fullUploaded byTJPRC Publications

- cssyll3.pdfUploaded bygujjar262069
- Dbms Lesson Plan With Out DatesUploaded byKiran Kumar
- Pcd Qtnpapernew(2017 18 Odd)Uploaded byKiran Kumar
- cssyllabus 3rdUploaded byKiran Kumar
- 10IS81Uploaded byKiran Kumar
- 1.INS QBQNKUploaded byKiran Kumar
- DESIGN AND ANALYSIS OF ALGORITHMS LABORATORY 10CSL47Uploaded byPradyot SN
- Final St ManualUploaded byKiran Kumar
- VTU Question Bank2014Uploaded byKiran Kumar
- Packet Drop.docUploaded byKiran Kumar
- SCH_10cs33Uploaded byKiran Kumar
- C# QPUploaded byKiran Kumar
- Best and Average ProjectsUploaded byKiran Kumar
- Ccp AssignmentUploaded byKiran Kumar
- SRS_SlideUploaded byRohini Shinde
- Alumni Common FormatUploaded byKiran Kumar
- UML sequence diagrams model the flow of logic within your system in a visual mannerUploaded byKiran Kumar
- Solution for Problem 1 AUploaded byKiran Kumar
- Exercise 2 10CSL57 DBMS LAB PROGRAM 2Uploaded byKiran Kumar
- Exercise 2 10CSL57 DBMS LAB PROGRAM 2Uploaded byKiran Kumar
- Oops Unit6 7 8 Rs25Uploaded byKiran Kumar
- Unit5 Notes SaUploaded byKiran Kumar
- Computer Organization Assignment-IsE 4th SemUploaded byKiran Kumar
- NS2 TutorialUploaded byJalajSrivastava
- IndiaUploaded byKiran Kumar
- Logic designUploaded byKiran Kumar

- Robocopy SortieUploaded byTSASS
- DB211 - Unit 7 Assignment AUploaded byTim Williams
- Cerebrum - Case Study Dutch ParliamentUploaded byVullnet Kabashi
- Poser Pro 2014 Quick Reference CardUploaded byRodrigo Silva
- Condition ExclusionUploaded byAnupa Wijesinghe
- Download Data From Web Ui to Excel and PPT - SAP CRMUploaded bykenguva_tirupati
- Oracle Migration ExadataUploaded byJesus Smith
- CatalogUploaded byParas Jain
- SQL2Uploaded bysridhiya
- 20060149-XLR-XL-Reporter-SBO-Training-ManualUploaded bychanhuileng6613
- Xiaomi Mi Band DCUploaded byvasiboss
- City Miami MicrofocusUploaded bydwnsouf77
- Regional-Adaptation--DTT-Network-TelenorUploaded bydominhson
- DVB InputsUploaded byjohnambasador
- Open Modbus TCP for NCM CP EnglishUploaded byRamón F. Zapata Sánchez
- BIApps11g Setup April2012Uploaded byparashar1505
- Manual Digital VisualizerUploaded byEliyawati Saydi
- ._Unit 11. Sistem Saraf - C. Neurofisiologi Motorik Dan IntegratifUploaded byLintang Odhy
- IJETT-V2I3P202Uploaded bysurendiran123
- SRE Lecture # 1Uploaded byahsan_naich7486
- What's New in Pro Tools 12.5.1Uploaded bypsyevil
- Mb ShareefUploaded bymohadsha
- ReRAM Secound PaperUploaded byAtul Dwivedi
- (8) Ethical Hacking Course in Hindi Urdu - YouTubeUploaded byVikas Razdan
- Cognitive Radio Cognitive Network SimulatorUploaded byChandra Mohanty
- An Algorithm for Generating Non-Redundant Sequential Rules for Medical Time Series DataUploaded byAnonymous lPvvgiQjR
- Itim NotesUploaded byapoorv0092
- Ha Bib AUploaded byHabiba Habbouba
- cen-idocUploaded byPerth Nikonian
- okc115trmUploaded bydavidapps12