For 100% Result Oriented IGNOU Coaching and Project Training Call CPD: ,

Similar documents
CAD Algorithms. Categorizing Algorithms

END-TERM EXAMINATION

Sankalchand Patel College of Engineering - Visnagar Department of Computer Engineering and Information Technology. Assignment

DESIGN AND ANALYSIS OF ALGORITHMS

L.J. Institute of Engineering & Technology Semester: VIII (2016)

CLASS: II YEAR / IV SEMESTER CSE CS 6402-DESIGN AND ANALYSIS OF ALGORITHM UNIT I INTRODUCTION

Introduction to Algorithms Third Edition

Theorem 2.9: nearest addition algorithm

About the Author. Dependency Chart. Chapter 1: Logic and Sets 1. Chapter 2: Relations and Functions, Boolean Algebra, and Circuit Design

Thomas H. Cormen Charles E. Leiserson Ronald L. Rivest. Introduction to Algorithms

Contents. 1 Introduction. 2 Searching and Traversal Techniques. Preface... (vii) Acknowledgements... (ix)

Data Structures and Algorithms (DSA) Course 13 Algorithms

Exercise 1. D-ary Tree

DATA STRUCTURES AND ALGORITHMS

Department of Computer Applications. MCA 312: Design and Analysis of Algorithms. [Part I : Medium Answer Type Questions] UNIT I

Algorithm classification

NP-Hardness. We start by defining types of problem, and then move on to defining the polynomial-time reductions.

CS6402-DESIGN AND ANALYSIS OF ALGORITHM. TWO MARK QUESTION WITH ANSWERS Unit-I. Introduction

CS6402 DESIGN AND ANALYSIS OF ALGORITHMS QUESTION BANK UNIT I

Unit-5 Dynamic Programming 2016

CS-6402 DESIGN AND ANALYSIS OF ALGORITHMS

Algorithms and Data Structures (INF1) Lecture 15/15 Hua Lu

The divide and conquer strategy has three basic parts. For a given problem of size n,

INSTITUTE OF AERONAUTICAL ENGINEERING

Computer Algorithms. Introduction to Algorithm

Analysis of Algorithms

More Complicated Recursion CMPSC 122

FINAL EXAM SOLUTIONS

5105 BHARATHIDASAN ENGINEERING COLLEGE

Algorithms and Data Structures

IN101: Algorithmic techniques Vladimir-Alexandru Paun ENSTA ParisTech

CSci 231 Final Review

Reference Sheet for CO142.2 Discrete Mathematics II

Advanced Algorithms and Data Structures

1 Format. 2 Topics Covered. 2.1 Minimal Spanning Trees. 2.2 Union Find. 2.3 Greedy. CS 124 Quiz 2 Review 3/25/18

Goal of the course: The goal is to learn to design and analyze an algorithm. More specifically, you will learn:

Chapter 9 Graph Algorithms

Algorithms in Systems Engineering IE172. Midterm Review. Dr. Ted Ralphs

CS 506, Sect 002 Homework 5 Dr. David Nassimi Foundations of CS Due: Week 11, Mon. Apr. 7 Spring 2014

Lecture 9: Sorting Algorithms

Parallel Sorting Algorithms

MAT 243 Test 2 SOLUTIONS, FORM A

DESIGN AND ANALYSIS OF ALGORITHMS

Data Structures and Algorithms

Design and Analysis of Algorithms - - Assessment

Programming II (CS300)

Chapter 9 Graph Algorithms

Multiple Choice Question. Unit-1 Introduction

15CS43: DESIGN AND ANALYSIS OF ALGORITHMS

Examples of P vs NP: More Problems

Sorting and Selection

Sorting Algorithms. For special input, O(n) sorting is possible. Between O(n 2 ) and O(nlogn) E.g., input integer between O(n) and O(n)

Topic 10 Part 2 [474 marks]

PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of MCA

Algorithms Interview Questions

Part I Basic Concepts 1

The Algorithm Design Manual

Advanced Algorithms and Data Structures

CS583 Lecture 01. Jana Kosecka. some materials here are based on Profs. E. Demaine, D. Luebke A.Shehu, J-M. Lien and Prof. Wang s past lecture notes

Greedy Algorithms 1 {K(S) K(S) C} For large values of d, brute force search is not feasible because there are 2 d {1,..., d}.

Lecture 1. Introduction

DISCRETE MATHEMATICS

10/31/18. About A6, Prelim 2. Spanning Trees, greedy algorithms. Facts about trees. Undirected trees

Spanning Trees, greedy algorithms. Lecture 20 CS2110 Fall 2018

Greedy Algorithms CSE 6331

Spanning Trees 4/19/17. Prelim 2, assignments. Undirected trees

Spanning Trees. Lecture 22 CS2110 Spring 2017

Anany Levitin 3RD EDITION. Arup Kumar Bhattacharjee. mmmmm Analysis of Algorithms. Soumen Mukherjee. Introduction to TllG DCSISFI &

Discrete Mathematics 1

Problem. Input: An array A = (A[1],..., A[n]) with length n. Output: a permutation A of A, that is sorted: A [i] A [j] for all. 1 i j n.

Programming II (CS300)

UNIT 5B Binary Search

4. Give the diagram representation of Notion of algorithm. [M 13]

ECS122A Lecture Notes on Algorithm Design and Analysis

Data Structures, Algorithms & Data Science Platforms

Decreasing a key FIB-HEAP-DECREASE-KEY(,, ) 3.. NIL. 2. error new key is greater than current key 6. CASCADING-CUT(, )

Sorting. Sorting in Arrays. SelectionSort. SelectionSort. Binary search works great, but how do we create a sorted array in the first place?

UNIT 1 BASICS OF AN ALGORITHM

CSE 101 Homework 5. Winter 2015

Outline Purpose How to analyze algorithms Examples. Algorithm Analysis. Seth Long. January 15, 2010

Ph.D. Comprehensive Examination Design and Analysis of Algorithms

Model Answer. Section A Q.1 - (20 1=10) B.Tech. (Fifth Semester) Examination Analysis and Design of Algorithm (IT3105N) (Information Technology)

Greedy algorithms. Given a problem, how do we design an algorithm that solves the problem? There are several strategies:

Final. Name: TA: Section Time: Course Login: Person on Left: Person on Right: U.C. Berkeley CS170 : Algorithms, Fall 2013

D.K.M.COLLEGE FOR WOMEN (AUTONOMOUS), VELLORE-1.

UC Berkeley CS 170: Efficient Algorithms and Intractable Problems Handout 1 Lecturer: Michael Jordan August 28, Notes 1 for CS 170

Visualizing Data Structures. Dan Petrisko

Unit-2 Divide and conquer 2016

Assignment 1 (concept): Solutions

Limitations of Algorithmic Solvability In this Chapter we investigate the power of algorithms to solve problems Some can be solved algorithmically and

CS521 \ Notes for the Final Exam

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

Fundamental mathematical techniques reviewed: Mathematical induction Recursion. Typically taught in courses such as Calculus and Discrete Mathematics.

Stanford University CS261: Optimization Handout 1 Luca Trevisan January 4, 2011

Fast Sorting and Selection. A Lower Bound for Worst Case

1. [1 pt] What is the solution to the recurrence T(n) = 2T(n-1) + 1, T(1) = 1

COMP 355 Advanced Algorithms Approximation Algorithms: VC and TSP Chapter 11 (KT) Section (CLRS)

Introduction to Algorithms / Algorithms I Lecturer: Michael Dinitz Topic: Dynamic Programming I Date: 10/6/16

Design and Analysis of Algorithms CS404/504. Razvan Bunescu School of EECS.

Announcements. CSEP 521 Applied Algorithms. Announcements. Polynomial time efficiency. Definitions of efficiency 1/14/2013

Transcription:

ASSIGNMENT OF MCS-031(ADA) Question 1: (a) Show, through appropriate examples or otherwise, that the following three characteristics of an algorithm are independent (i) finiteness An algorithm must terminate after a finite number of steps and further each step must be executable in finite amount of time. In order to establish a sequence of steps as an algorithm, it should be established that it terminates (in finite number of steps) on all allowed inputs. (ii) definiteness Each steps of an algorithm must be precisely defined; the action to be carried out must be rigorously and unambiguously specified for each case. (iii) effectiveness it consists of basic instructions that are realizable. This means that the instructions can be performed by using the given inputs in a finite amount of time. (c) Arrange the following growth rates in increasing order: O ( (24)n ), O (n2), O (1), O (n log n) ANS- Order Of Notaion In Increasing Order:- 0(1) O(n) 1/2 o(n) o(nlogn) o(n 2 ) o(n 3 ) o(2 n ) order is o(1) < o(n logn) < o(n 2 ) < o(24 n )

(b) Let f (n) denote the nth term of a sequence of integers given (5 marks) by the equation f(n) = f(n-1) +f(n-2) for n > 2 and f(1) = 1 and f(2) = 1, then using principle of mathematical induction, show that 5 f( n ) = {(1+ 5) / 2} n -- {(1 -- 5) / 2}n for all n > = 1

ANS- For 100% Result Oriented IGNOU Coaching and Project

Question 2: Suppose that instead of binary or decimal representation ofintegers, we have ternary, along with 3 s complement,representation of integers, i.e., integers are represented using threedigits, viz., 0, 1,2. For example, the integer 47 is represented as01202 = (in decimal) 1. 33 + 2. 32 + 0. 31 + 2. 30, where, the leading zero indicates positive sign. And the integer ( 47 ) in 3 scomplement is represented by 11021, the leading 1 indicatesnegative sign. The other digits, except the right-most, in therepresentation of ( 47) are obtained by subtracting from 2 thecorresponding digit in 47 s representation, and then adding 1 (therepresentation of 47 is obtained as 11020 + 00001).Write a program for the arithmetic (negation of an integer,addition, subtraction and multiplication of two integers) of 4integers using 3 s complement representation. The program should include a procedure for calculating each of negation of an integer, addition, subtraction and multiplication of two integers. The integers will use 8-ternary digit positions, in which the left-most position will be used for sign. Using your program find the ternary representation of each of thedecimal numbers 345, -- 297, 18 and ( (345 -- 297) * 18) ans- Question 3: (a) Write a short note on each of the following: (i) Best case analysis In the best case analysis, we calculate lower bound on running time of an algorithm. We must know the case that causes minimum number of operations to be executed. In the linear search problem, the best case occurs when x is present at the first location. The number of operations in worst case is constant (not dependent on n). So time complexity in the best case would be o(1). (ii) amortized analysis This term refers to the analysis of algorithm performance based on a specific sequence of operations that targets the worst case scenario -- that is, amortized analysis does imply that the metric is worst case performance (although it still does not say which quantity is being measured). To perform this analysis, we need to specify the size of the input, but we do not need to make any assumptions about its form. In layman's terms, amortized analysis is picking an arbitrary size for the input and then "playing through" the algorithm. Whenever a decision that depends on the input must be

made, the worst path is taken¹. After the algorithm has run to completion we divide the calculated complexity by the size of the input to produce the final result. (b) Using one-by-one (i) bubble sort (ii) heap sort and (iii) quick sort, sort the following sequence in increasing order and analyze (i.e., find number of comparisons and assignments in each of ) the algorithm: 43, 28, 37, 18, 15, 40, 12 ans-

Question 4:

(a) The following pseudo-code is given to compute ( a b )mod n, where a, b and n are positive integers. Trace the algorithm to compute 7 560 mod 561 MODULAR-EXPONENTION (a, b, n) 1. c 0 { variable c is assigned 0} 2. d 1 3. let (bk, bk -- 1,, B0) be binary representation of b 4. for i k downto 0 5. do c 2c 6. d (d. d) mod n 7. if bi = 1 8. then c c+1 9. d (d. a) mod n 10. end-do 11. return d. (b) Explain the essential idea of Dynamic Programming. How does Dynamic Programming differ from Divide and conquer approach for solving problems? Ans Dynamic Programming is a technique for solving problems with overlapping subproblems. Each sub-problem is solved only once and the result of each sub-problem is stored in a table ( generally implemented as an array or a hash table) for future references. These sub-solutions may be used to obtain the original solution and the technique of storing the sub-problem solutions is known as memoization. Dynamic Programming Breaks the problem down into discrete subproblems. The recursive algorithm for the Fibonacci sequence is an example of Dynamic Programming, because it solves for fib(n) by first solving for fib(n-1). In order to solve the original problem, it solves a different problem. Divide and Conquer These algorithms typically solve similar pieces of the problem, and then put them together at the end. Mergesort is a classic example of divide and conquer. The main difference between this example and the Fibonacci example is that in a mergesort, the division can (theoretically) be arbitrary, and no matter how you slice it up, you are still merging and sorting. The same amount of work has to be done to mergesort the array, no matter how you divide it up. Solving for fib(52) requires more steps than solving for fib(2).

Question 5: (a) For the graph given in Figure below, use DFS to visit various vertices. The vertex B is taken as the starting vertexand, if there are more than one vertices adjacent to a vertex,then the adjacent vertices are visited in lexicographic order. (b) In context of graph search, explain the minimax principle. Ans- Minimizing the maximum losses that could occur in an event or situation is this specific type of decision-making principle. Should a strategy fail, this financial and business strategy measures potential results leading to the least amount of regret. By the use of logic, determine and use this strategy. Aids deciding when presented with two various and conflicting strategies. A principle for decision-making by which, when presented with two various and conflicting strategies, one should, by the use of logic, determine and use the strategy that will minimize the maximum losses that could occur. This financial and business strategy strives to attain results that will cause the least amount of regret, should the strategy fail.

Question 6: (a) Is there a greedy algorithm for every interesting optimization problems? Justify your Claim. Ans- A greedy algorithm is an algorithm that follows the problem solving heuristic of making the locally optimal choice at each stage with the hope of finding a global optimum. In many problems, a greedy strategy does not in general produce an optimal solution, but nonetheless a greedy heuristic may yield locally optimal solutions that approximate a global optimal solution in a reasonable time. For example, a greedy strategy for the traveling salesman problem (which is of a high computational complexity) is the following heuristic: "At each stage visit an unvisited city nearest to the current city". This heuristic need not find a best solution but terminates in a reasonable number of steps; finding an optimal solution typically requires unreasonably many steps. (b) Apply each of (i) Prim s and (ii)kruskal s algorithms one at a time to find minimal spanning tree for the following graph.

Question 7: Write note on each of the following: (20 marks) (i) Unsolvability/ undecidability of a problem (ii) Halting problem (iii) Reduction of a problem for determining decidability (iv) Rice theorem ans- In computability theory, Rice's theorem states that, for any non-trivial property of partial functions, there is no general and effective method to decide whether an algorithm computes a partial function with that property. Here, a property of partial functions is called trivial if it holds for all partial computable functions or for none, and an effective decision method is called general if it decides correctly for every algorithm. (v) Post correspondence problem (vi) NP-complete problem (vii) K-colourability problem (viii) Independent set problem