Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

DAA(supply prep)

Unit 1:
Recursive Algorithms: (Algorithm Specification)

 A recursive function is a function that is defined in terms of


itself.
 Similarly, an algorithm is said to be recursive if the same
algorithm is in the body.
 Then that algorithm is known as direct recursive.
 Algorithm A is said to be indirect recursive if it calls another
algorithm in its body which in turn calls A.

Randomized Algorithms:

 A randomized algorithm is one that uses randomizer (the one


that produces random number generator)
 Randomized algorithm is a deferent design approach taken by
the standard algorithm where random bits are added to the
part of their logic.
 Randomized algorithm produces different outputs every time
they execute.
 It is important to note that it is not the input that is randomized
but the logic of the standard algorithm.
 Randomized algorithm also produces wrong outputs, to avoid
these erroneous outputs, a process called amplification is
performed.
 Amplification is also an algorithm that is applied to execute
some parts of randomized algorithm for output of correctness.
 But too much of amplification can lead to ineffectiveness of
randomized algorithm.
Classification of randomized algorithm:
Randomized algorithm is classified based on whether they have
time constraints of random variables or deterministic values.
There are two types of RA:
1) Las Vegas
2) Monte Carlo.
Las Vegas: Las Vegas method of randomized algorithm never
produces wrong output. It always produces correct output.
Therefore, time constraint is the random variable
For example, if an algorithm gets an error, it executes again from
the starting. Randomized quick sort is one of the examples.
Monte Carlo: monte Carlo method of randomized variable focus
on the completion of execution of the program. Therefore,
running time is deterministic.
For example, it gets an error at a particular statement it continues
the execution again from that statement. Karger’s minimum cut
algorithm is one of the examples.

Unit 2
The greedy method:
https://www.tutorialspoint.com/data_structures_algorithms/
greedy_algorithms.htm
Knapsack problem:
https://byjusexamprep.com/gate-cse/knapsack-problem-using-
greedy-method

optimal merge pattern:


https://www.tutorialspoint.com/data_structures_algorithms/
optimal_merge_pattern_algorithm.htm

0/1 knapsack:
https://www.geeksforgeeks.org/0-1-knapsack-problem-dp-10/

You might also like