0% found this document useful (0 votes)
10 views14 pages

Unit I-Worksheet

The document discusses algorithms including their definition, characteristics, and techniques for designing algorithms. It provides examples of algorithms for finding the maximum number, searching an array, and decoding sentences. It also covers analyzing algorithms including best, worst, and average case time complexity.

Uploaded by

NithyaKalyani A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views14 pages

Unit I-Worksheet

The document discusses algorithms including their definition, characteristics, and techniques for designing algorithms. It provides examples of algorithms for finding the maximum number, searching an array, and decoding sentences. It also covers analyzing algorithms including best, worst, and average case time complexity.

Uploaded by

NithyaKalyani A
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 14

22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1

Session 1- Introduction, Fundamentals of algorithm


Fundamentals
1. Algorithm is a , which defines a

to be executed in certain order to get the desired

output.

2. An algorithm can be implemented in more than one programming language. (True / False)

3. Any procedure for an operation can be called as algorithm (True / False)

4. State any 3 basic definitions of algorithm

5. List the characteristics of an algorithm

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

2. Differentiate algorithm and pseudo-code

Algorithm Pseudo code

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

Session – 2 Algorithm Design Techniques


Recap: Introduction, Fundamentals of algorithm

Solve the following puzzle

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

3. Define Brute force

Brute force is a straightforward approach to solve a problem based on

and of the concepts

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

Match the following


1. An optimal solution to the problem
contains an optimal solution to i. State Space Search problems
Sub-problems.

2. Backtracking ii. Priority Queue

3. Branch and bound algorithms iii. Prims algorithm

4. Divide and conquer iv. Overlapping sub-problems.

5. Dynamic Programming v. Optimal substructure

6. Expanding a partially constructed vi. N queen problem


solution obtained so far

7. Greedy Algorithm vii. Minimal spanning tree

8. Greedy-choice property viii. Huffman coding

9. Problem instance is reduced by a ix. Greedy algorithm


constant

10. Problem instance is reduced by a factor x. Floyd Warshall algorithm

11. Useful for small size problems xi. Divide and Conquer

xii. Decrease and conquer

xiii. Brute force

xiv. Binary Search

xv. A global optimum can be arrived at by


selecting a local optimum

Short questions
1. List out the different design paradigm/ design approaches for algorithm.
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1

2. Define Divide and Conquer method with example

3. Describe Brute force method

4. Differentiate Greedy method and Dynamic Programming


Greedy Method Dynamic Programming

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)

Recap: Algorithm Design Techniques


Quiz
1. Two main measures for the efficiency of an algorithm are

a. Processor and memory b. Complexity and capacity

c. Time and space d. Data and space

2. The time factor when determining the efficiency of algorithm is measured by

a. Counting microseconds b. Counting the number of key operations

c. Counting the number of statements d. Counting the kilobytes of algorithm

3. The Worst case occur in linear search algorithm when

a. Item is exactly in the middle of the array

b. Item is not in the array at all

c. Item is the last element in the array

d. Item is the first element in the array or is not there at all

4. An algorithm is said to be efficient and fast, if it takes

 .

5. The complexity of an algorithm f(n) gives the running time and / or storage space required by the

algorithm in terms of n, where n represents .

Algorithm analysis
6. Three types of time complexity
22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1

7. : Computation of running time entails knowing all possible

input sequences, the probability distribution of occurrence of these sequences, and the running

times for the individual sequences.

8. : It is the function defined by the maximum amount of time

needed by an algorithm for an input of size n.

9. : It is the minimum amount of time that an algorithm requires

for an input of size n.

10. List the four rules to count the operations:

Short Questions
1. List out the steps involved in analysis of non-recursive algorithms

2. Describe about time complexity and space time complexity of an algorithm


22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1

Session 4: Asymptotic Notations (O, Ω, ʘ) based on Orders of Growth


1. Calculate the time taken for the following code and specify the rules followed

function (a[n], key)

1.for( i = 0; i < n; i++)

2. if (a[i] == key)

3. return i;

4.return -1;

2. Draw the Figure

3. Write the function for Big O notation

4. write the function for the following


22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1

5. Fill up the table

Algorithms Best case Average case Worst case

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

Session 4,5,6 & 7: Mathematical Analysis


1. Define recursion

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

4. List the methods to solve the recurrences

5. Describe the steps involved in Substitution method:

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

7. Write the three cases for Masters theorem


22CII42- DESIGN AND ANALYSIS OF ALGORITHMS MODULE 1

Short questions [6 marks]


1. Solve and find the complexity for the following recurrence relations using Masters
theorem T (n) = 4 T (n/2) + n

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

You might also like