Unit I-Worksheet
Unit I-Worksheet
output.
2. An algorithm can be implemented in more than one programming language. (True / False)
1.
2.
3.
4.
5.
6.
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1
Design an Algorithm
Design an algorithm to find the maximum number out of three given number
Step 1:
Step 2:
Step 3:
Step 4:
Step 5:
Design an algorithm
Design an algorithm to search an element from a given n numbers in an array using Linear
Search
Step 1:
Step 2:
Step 3:
Step 4:
Step 5:
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1
Short questions
1. Define algorithm
Big Questions
1. Write an algorithm and Pseudo code for searching an element from an array of n elements using
Binary Search
2. Write an Algorithm and pseudo code to sort n numbers in an array using bubble sort method
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1
Across
1. Algorithm should be clear
4. Algorithm must stop after
100 iterations
5. English with
programming language
6. Not all can be
called as algorithm
7. Step by Step procedure
Down
2. Algorithm for all
programming languages
3. program is possible
with available resources
Activity 2:
1. Can you list down different approaches/design paradigms to solve any problem
1 5
2 6
3 7
4 8
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1
O R M I G
21 2 12 5 16 20
2. List any (or many) example.
Brute force
Divide-and-Conquer
Backtracking
Greedy
involved.
4. Read Decode Sentences: Read the codes for the corresponding alphabets, On the basis of
above code, decode the following numbers to make words and complete the Sentence.
C A H R T W E D B S Y F X
1 5 7 2 11 8 9 18 3 15 19 4 25
U J I K M G N L P O V Z Q
6 10 17 13 16 12 20 14 21 22 23 24 26
D i i e
23 18 18 19 20 5 16 17 1
5 20 18
o q e
1 20 6 2
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1
11. Useful for small size problems xi. Divide and Conquer
Short questions
1. List out the different design paradigm/ design approaches for algorithm.
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1
Big Questions
1. Write detailed notes on different techniques / approaches to design an algorithm.
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1
Session 3: Designing an algorithm and its Analysis (Best, Worst & Average case)
.
5. The complexity of an algorithm f(n) gives the running time and / or storage space required by the
Algorithm analysis
6. Three types of time complexity
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1
input sequences, the probability distribution of occurrence of these sequences, and the running
Short Questions
1. List out the steps involved in analysis of non-recursive algorithms
2. if (a[i] == key)
3. return i;
4.return -1;
Linear Search
Binary Search
Bubble Sort
Insertion Sort
Big Question:
1. Write detailed notes on asymptotic notations with necessary diagrams.
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1
2. Write an example for recurrence relation and name the base case and recursive case
3. Find the exact solution to the recurrence relation using mathematical induction method
Solution:
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1
1)
2) Use to find constants in the form and show that the solution works..
6. Draw the recurrence tree for the function T(n) = T(n/4) + T(n/2) + cn2
2. Solve and find the complexity for the following recurrence relations using Masters
theorem T (n) = 2 T (n/2) + n log n
3. Solve and find the complexity for the following recurrence relations using Masters
theorem T (n) = T (n/3) + n