Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
100%
(1)
100% found this document useful (1 vote)
2K views
290 pages
Design and Analysis of Algorithms-Compressed (1) - Compressed
Uploaded by
Jayanth RS
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Design and Analysis of Algorithms-compressed (1)_c... For Later
Download
Save
Save Design and Analysis of Algorithms-compressed (1)_c... For Later
100%
100% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
100%
(1)
100% found this document useful (1 vote)
2K views
290 pages
Design and Analysis of Algorithms-Compressed (1) - Compressed
Uploaded by
Jayanth RS
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download now
Download
Save Design and Analysis of Algorithms-compressed (1)_c... For Later
Carousel Previous
Carousel Next
Download
Save
Save Design and Analysis of Algorithms-compressed (1)_c... For Later
100%
100% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 290
Search
Fullscreen
Dyn) il} INHIB Of CS) TASS For VI Sem As pec the Syllabus of A awa 89107842 A PUBLISHERSGolo 34x42 Design & Analysis of Algorithms For Sixth Semester B.C.A As per Bangalore University Syllabus ‘ BY Srikanth .S REFERENCE BOOK Skyward Publishers 11157, 3rd Main, 70-Cross, Chamara|zet, Bengalora - 560018 Ph --080-26603525/ 44559339 Mob -61 1185999 / 4559514760 ‘rail -
[email protected]
wwwaskywardpeblisherscam
mi | GCD (m,n) = " ifn=0 GCD (n,.MOD(n,1)), otherwise Here, MOD (im, n) is nothing “7 modulo n” i.e., the remainder obtained when dividing 7 bye. The thitd part of the equality ie., GCD (n,n) = GED in, MOD (in, n)) is the heart | ofthe problem which is applied repestedly until MOD (m, n) becomes zero thumple: GCD (288, 108) = GCD (108, MOD (288. 108)) GCP (108, 72) = GCD (72, MOD (108, 723) (D (72,36) = GCD (36, MOP (72, 36) = GCP 36.0) = 36 So, the following steps are adapted according to Buclid. Step I:Check the second equality first in the definition ie. ifm = 0, return the value of mm! and-stop. Otherwise go to step 2. Stop 2:Caleulate MOD. (ma, 1} and assign this value'to a temporary variable“? Step 3:Assign the value of ‘i! to ‘in’ and ‘t' to ‘x’, Go to step 1 Algorithm : Euclid (vt, 7) 1 Computing the GCD (m, nm} ‘Input ; lwo non-negative, not-both-zere integers m, 2 /) Qutput : Greatest common divigor of m and n #@ do in mod np ag is 8 “0 return’ fm ; y {f we recall the features of an algorithm, the first feature that the algorithm should terminate after a particular number of steps is true in this example. The terminating step here is, when ahecomes ‘0’ i.e., MOD (m,n) becomes zero i.¢., the second equality step GCD (mm, t= me,6 The Design & Analysis of atenith Technique 2: (Consecutive Integer checking algorithm) Thiis technique is based on the general definition of a GC thata GCD is the largest integer that divides both the numbers evenly: Obviously, suet ‘an integer cannot be greater than any of the {wo integers, Sa GED (m, n) $ min (m, n}. Let us consider GCD (m,n) as a temporary votable '¢' and assign the minimum of m undo the variable (4.8. 1= are (i, 0). Now westait ohevking whether ‘f divides both mund 7. Llitdoes, the GCD (m, n)is ‘1’ otherwise decrease ‘by Land check once again. ‘The process continues until ‘r' reaches a number that divides both mand n. Example: Consider the sane example GCP (288, 108) ics m= 288, a= 108 and t= min (288, 108) = 108 Now check whether MOD (mt, )=0 As MOD (288, 108) #0, decrease rby Live. f= 107. Now, as MOD (288, 107) #=0, decreases by Lie. r= 106 Again, as MOD (288, 106) 40, decreases by | i.e, 7= 105 Again, as MOD (288, 97) #0, decrease by 1 1c.,1=96 But, as MOD (288, 96) = 0, Now check whether MOD (n, r) =0 As MOD (108, 96) # 0, decrease ( by Lie. t=95 and check whether MOD (m, t)=0. As MOD (288, 95) #0, decrease rby 1 ie. r=94 Now, ds MOD (288, 94) #0, deerease t by Lie. t= 93 Again as MOD (288, 93) #0, decrease t by
[email protected]
=92 Again, as MOD (288, 73) #0, decrease r by i.e. But, as MOD (283, 72)=0,Anyeadiction Now check whether: MOD (n,)=0- As MOD (108,72) #0, decrease by Lie.,1=71 and check whether MOD (mm; n=0 As MOD(288, 71) #0, decrease rby 1 ie, r= 70 Again, As MOD (288, 37) # 0, dectéase t by Lie. r=36 But, as MOD (288, 36) =0, Now check whether MOD (n, )=0 ‘As MOD (108,36) = ‘The result is 36, 80°36’ is the greatest common divisor thatdivides both 288 and 108. The following steps can be adopted for this, Step T: Assign the value of min {ma 2} to Step 2: Calculate MOD (m, 1). Witis zero, goto step 3, else go to step4. Step 3: Calculate MOD (n, 1). [fitis “zero”, return the value of as answer and stop, else g0 10 slep-4, Step 4: Decrement ‘7 by | and goto step 2. Algorithm: CICA (m,n) Vi iy Il Computing the Gcn im, aj Taput : Two. nm Negative, net-both zero integers m, n. Output + Greatest common divisor of mand 2. & = min (a, a); while (t #1) do t=mmod cj} if (t = 0) a b= nmod tj d= (tu = 0) fi return t ;8 . hs Desiew a Analysis of Ala ‘The drawback in this alporithm techniques it doesn't Work when any one or both of the input vuluési-e.. mand mare zeros, because when any One of mand are zeros, the minimum: value becomes *0’ Le..f=0. Then MOD (m, 1) or MOD (u, t) isnot defined, So theextrucondition forinput when perférming this algorithm is'the integers should be non-negative, nol-zero, ‘Technique 3 (Middle - School Algorithm) ‘The third technique is the one thatis more familiar tothe middle =school students and hence the atric, iy this method, thie prime factors ot the integers are found and then by identifying all Ot common terms and multiplying them gives the gel. Example: GED (288, 108) ‘The prime factors of 288 =2°X 3? g| ton = -2| 288 The prime factors of 108 =2" 38 gisa = 1 Noiw, thecommon terms are 2? and 3* ee “+, The ged of 288 and 108=2?x3'=4x9=36 © 912 _ Boe “The steps involved in this prozess F oe Stop 1: Find the prime factors of eT Step 2: Step 3: Identify the common prime factors of the above (wo step factors. ‘ind the prime factors of 1 Step 4: Compute the product of the comrnon factors of step 3 and return the resull which is th ged. Designing wn algorithm for this technique is: more complex though the way we followed in th example looks very eusy because using a pen we can calculate the prime factors and th commion prime factors very easily but the computer will take a large amount of time fe performing this method.. 9 liviadacsiow Soun algorithm for generating the consecutive primes is inverted in ancient greace and is named as sieve of Erasthenes. Sieve of Erasthenes: This generates all of the prime numbers less than or equal ton. Start by writing the numbers from 2, 3,4... 2 ina line. Then keep repeating the following process until all the elements or numbers less than or equal to va haye been crossed out or circled. Circle the next number whieh is neither circled nor crossed out, and cross out all other multiples of thal number which are in the list (some of these are probably already erossed out). The numbers which are not crossed out when the process terminates are all of the primes between 2 tom. Example {: To list out the prime numbers less than or equal to 36, i.e., when n= 36 2|3 |4]5 |e ]7 |e nm [t2 | ra | a fas Ff 18 20 | 24 | 22 | 28 25 | 26 | 27 | 28] 30 | 1/82 | 33 | 84 | 35 | 36 The square root of 36 is 6 and therefore we haye to repeat the process mentioned earlier until all the elements are crossed out or circled lessthan or equal to 6. Consider a first number 2, which is-not yet circled or crossed out. Circle the number 2 and crossout all the multiples of 2 except 2 i.¢., 4, 6.8, 1 a a 7 9 i 13 15 Ww lo 21 23 [Set] 25 [ae] 27 2 al 3B. aD ‘Consider the next number which is neither crossed out nor circled. i.e., number 3. Now, cirele the number’ and cross out all the multiples of 3 except 3, fe, (6, 9, 12,15, ....2. 33, 36), [some of them are-already crossed out, then'no need to cross them again W 13 7 19: od 23 29 3
You might also like
ADA TEXTBOOK SKYWARD
PDF
100% (1)
ADA TEXTBOOK SKYWARD
405 pages
Design & Analysis of Algorithms Lab Manual
PDF
50% (2)
Design & Analysis of Algorithms Lab Manual
84 pages
Decision Properties of Regular Languages
PDF
No ratings yet
Decision Properties of Regular Languages
33 pages
Bootstrapping in Compiler Design
PDF
90% (20)
Bootstrapping in Compiler Design
12 pages
Introduction To Algorithms
PDF
No ratings yet
Introduction To Algorithms
4 pages
250+dsa Questions For Placements
PDF
50% (4)
250+dsa Questions For Placements
13 pages
DAA TechKnowledge
PDF
No ratings yet
DAA TechKnowledge
195 pages
Daa Notes
PDF
100% (1)
Daa Notes
127 pages
Design and Analysis of Algorithms - CS8452
PDF
No ratings yet
Design and Analysis of Algorithms - CS8452
6 pages
Data Structure Best Dsa Notes
PDF
No ratings yet
Data Structure Best Dsa Notes
98 pages
Design & Analysis of Algorithms - Topic 1 - Introduction to Course
PDF
No ratings yet
Design & Analysis of Algorithms - Topic 1 - Introduction to Course
29 pages
Write A Program To Implement Job Sequencing Algorithm
PDF
64% (11)
Write A Program To Implement Job Sequencing Algorithm
2 pages
R Lab Manual
PDF
No ratings yet
R Lab Manual
19 pages
Data Structures and Algorithms in Java - (Cuuduongthancong - Com)
PDF
No ratings yet
Data Structures and Algorithms in Java - (Cuuduongthancong - Com)
526 pages
Algorithms Notes For Professionals
PDF
100% (3)
Algorithms Notes For Professionals
253 pages
DAA All 5 Units Notes
PDF
No ratings yet
DAA All 5 Units Notes
87 pages
nt1 (1)
PDF
No ratings yet
nt1 (1)
132 pages
DAA Notes
PDF
No ratings yet
DAA Notes
115 pages
Daa Notes
PDF
No ratings yet
Daa Notes
114 pages
Daa Unit 3 Daa Unit 3 Handwritten Notes
PDF
100% (1)
Daa Unit 3 Daa Unit 3 Handwritten Notes
20 pages
Numpy Handwritten Notes
PDF
No ratings yet
Numpy Handwritten Notes
8 pages
ADA Notes-NEP 2023-1
PDF
No ratings yet
ADA Notes-NEP 2023-1
17 pages
KDU-SEN204-DesignandAnalysisofAlgorithm
PDF
No ratings yet
KDU-SEN204-DesignandAnalysisofAlgorithm
60 pages
Department of Information Technolo
PDF
No ratings yet
Department of Information Technolo
116 pages
Learn C Programming
PDF
100% (9)
Learn C Programming
169 pages
Natural Language Processing
PDF
100% (6)
Natural Language Processing
309 pages
Dunham - Data Mining PDF
PDF
83% (6)
Dunham - Data Mining PDF
156 pages
Python Cheat Sheets
PDF
97% (33)
Python Cheat Sheets
11 pages
Solved Questions Competitive Programming
PDF
No ratings yet
Solved Questions Competitive Programming
119 pages
Coding Patterns
PDF
100% (1)
Coding Patterns
26 pages
Design and Analysis of Algorithm
PDF
No ratings yet
Design and Analysis of Algorithm
116 pages
Compiler (Statement of Problem)
PDF
No ratings yet
Compiler (Statement of Problem)
58 pages
Digital Notes Daa
PDF
No ratings yet
Digital Notes Daa
169 pages
Classic Data Structures by D. Samanta
PDF
50% (2)
Classic Data Structures by D. Samanta
99 pages
Python 3 Cheat Sheet
PDF
94% (51)
Python 3 Cheat Sheet
2 pages
TOC - NOTES - 1 - Compressed
PDF
No ratings yet
TOC - NOTES - 1 - Compressed
122 pages
Algorithms Design and Analysis by Udit Agarwal PDF
PDF
67% (15)
Algorithms Design and Analysis by Udit Agarwal PDF
245 pages
UNIT5 - Comparison Tree
PDF
No ratings yet
UNIT5 - Comparison Tree
52 pages
Algorithms Illuminated Part3
PDF
100% (5)
Algorithms Illuminated Part3
230 pages
System Design Interview Fundamentals
PDF
100% (4)
System Design Interview Fundamentals
412 pages
Core Java Durga Sir
PDF
84% (25)
Core Java Durga Sir
850 pages
IMP Questions ADA
PDF
No ratings yet
IMP Questions ADA
7 pages
Data Structures by D Samantha PDF
PDF
No ratings yet
Data Structures by D Samantha PDF
167 pages
Ada Mod1 PPT Notes
PDF
No ratings yet
Ada Mod1 PPT Notes
55 pages
100 Java Programs With Output Useful Collection of Java Programs - Aniket Pataskar
PDF
86% (64)
100 Java Programs With Output Useful Collection of Java Programs - Aniket Pataskar
112 pages
Data Structures
PDF
100% (4)
Data Structures
275 pages
Computer Graphics Notes - TutorialsDuniya
PDF
100% (1)
Computer Graphics Notes - TutorialsDuniya
188 pages
Co Po Mapping Justification DSA
PDF
No ratings yet
Co Po Mapping Justification DSA
3 pages
Artificial Intelligence With Python (Machine Learning Foundations, Methodologies, and Applications) (Teik Toe Teoh, Zheng Rong)
PDF
93% (15)
Artificial Intelligence With Python (Machine Learning Foundations, Methodologies, and Applications) (Teik Toe Teoh, Zheng Rong)
334 pages
BSC CsIt Complete RDBMS Notes
PDF
No ratings yet
BSC CsIt Complete RDBMS Notes
86 pages
MCA Data Structures With Algorithms 01
PDF
No ratings yet
MCA Data Structures With Algorithms 01
16 pages
Priority Search Trees
PDF
100% (1)
Priority Search Trees
18 pages
Unit - V
PDF
100% (1)
Unit - V
22 pages
DAA Viva Questions
PDF
100% (1)
DAA Viva Questions
15 pages
An Insiders Guide To Ace System Design in - Maurice Jayson
PDF
100% (2)
An Insiders Guide To Ace System Design in - Maurice Jayson
60 pages
Competitive Programming in Python 128 Algorithms To Develop Your Coding Skills
PDF
100% (8)
Competitive Programming in Python 128 Algorithms To Develop Your Coding Skills
267 pages
Data Structures and Algorithms in C++
PDF
89% (9)
Data Structures and Algorithms in C++
738 pages
Design and Analysis of Algorithms: III Year II-sem (CSE)
PDF
No ratings yet
Design and Analysis of Algorithms: III Year II-sem (CSE)
79 pages
DAA Notes Jntu
PDF
No ratings yet
DAA Notes Jntu
45 pages
Coding Interview-Leetcode
PDF
83% (6)
Coding Interview-Leetcode
181 pages
ADA Complete Notes
PDF
33% (3)
ADA Complete Notes
151 pages
Important Questions Unit-1: I Introduction: Algorithms, Analyzing Algorithms, Complexity of Algorithms, Growth of
PDF
No ratings yet
Important Questions Unit-1: I Introduction: Algorithms, Analyzing Algorithms, Complexity of Algorithms, Growth of
7 pages
The Python Bible
PDF
97% (31)
The Python Bible
506 pages
Practical Projects
PDF
100% (29)
Practical Projects
478 pages
Daa Lecture Notes
PDF
No ratings yet
Daa Lecture Notes
120 pages
Algorithms For Data Science 1st Brian Steele (WWW - Ebook DL - Com)
PDF
100% (15)
Algorithms For Data Science 1st Brian Steele (WWW - Ebook DL - Com)
438 pages
Machine Learning - An Applied Mathematics Introduction PDF
PDF
100% (13)
Machine Learning - An Applied Mathematics Introduction PDF
246 pages
Full Course of Machine Learning
PDF
100% (16)
Full Course of Machine Learning
660 pages
Discrete Mathematical Structures 15CS36: Course Objectives: This Course Will Enable Students To
PDF
No ratings yet
Discrete Mathematical Structures 15CS36: Course Objectives: This Course Will Enable Students To
53 pages
Machine Learning Projects Python
PDF
94% (18)
Machine Learning Projects Python
134 pages
C Lab Manual
PDF
No ratings yet
C Lab Manual
16 pages
Challenges InThreading A Loop - Doc1
PDF
100% (2)
Challenges InThreading A Loop - Doc1
6 pages
Hackers Guide To Machine Learning With Python PDF
PDF
100% (15)
Hackers Guide To Machine Learning With Python PDF
272 pages
Two-Stack PDA: CS6800 Advance Theory of Computation
PDF
No ratings yet
Two-Stack PDA: CS6800 Advance Theory of Computation
51 pages
Introduction To The Design and Analysis of Algorithms - Lecture Notes, Study Material and Important Questions, Answers
PDF
No ratings yet
Introduction To The Design and Analysis of Algorithms - Lecture Notes, Study Material and Important Questions, Answers
16 pages
DS - Lab (KCS-351) Manual
PDF
No ratings yet
DS - Lab (KCS-351) Manual
65 pages
Data Structure and Algorithmic Thinking With Python Data Structure and Algorithmic Puzzles PDF
PDF
95% (21)
Data Structure and Algorithmic Thinking With Python Data Structure and Algorithmic Puzzles PDF
471 pages
Python Notes For Professionals
PDF
100% (17)
Python Notes For Professionals
814 pages
Data Structure Viva Questions
PDF
No ratings yet
Data Structure Viva Questions
3 pages
Write C Programs To Illustrate The Following IPC Mechanisms: A) Pipes
PDF
No ratings yet
Write C Programs To Illustrate The Following IPC Mechanisms: A) Pipes
6 pages
Understanding Machine Learning
PDF
100% (69)
Understanding Machine Learning
416 pages
The Python Manual
PDF
97% (31)
The Python Manual
196 pages
DAA Question Bank
PDF
No ratings yet
DAA Question Bank
39 pages
BCA Data Structures Notes
PDF
No ratings yet
BCA Data Structures Notes
24 pages
Cs6402 DAA Notes (Unit-3)
PDF
No ratings yet
Cs6402 DAA Notes (Unit-3)
25 pages
Data Structure and Algorithms With Python
PDF
100% (14)
Data Structure and Algorithms With Python
369 pages
Digital Search Tree
PDF
No ratings yet
Digital Search Tree
30 pages
Unit 1 - Data Structure - WWW - Rgpvnotes.in
PDF
No ratings yet
Unit 1 - Data Structure - WWW - Rgpvnotes.in
8 pages
Ada Lab Manual
PDF
No ratings yet
Ada Lab Manual
57 pages
Design and Analysis of Algorithms Laboratory 10CSL47
PDF
No ratings yet
Design and Analysis of Algorithms Laboratory 10CSL47
28 pages