SlideShare a Scribd company logo
Assignment: 2
Design & Analysis of algorithm
Total marks: 5
This assignment is compulsory for all including roll no 30 and 71.
This assignment is to be submitted tomorrow latest by 5 PM. If you fail to submit it
tomorrow 3 marks will be deducted. You may submit it on Friday with a penalty of 3
marks. After Friday no submission will be accepted and no marks will be given.
From 23rd
April no presentation will be held. For remaining students an extra
assignment will be given. For tomorrow, three next groups may (not necessary) give
presentations (Last presentation).
Dynamic Programming Technique:
Q1: What does dynamic programming has in common with divide-and-conquer? What is a
principal difference between them?
Q2: Design an efficient algorithm for computing the binomial coefficient C(n, k) that uses no
multiplications. What are the time and space efficiencies of your algorithm?
Q3: Rod-cutting problem: Design a dynamic programming algorithm for the following
problem. Find the maximum total sale price that can be obtained by cutting a rod of n units
long into integer-length pieces if the sale price of a piece i units long is pi for i = 1, 2, . . . , n.
What are the time and space efficiencies of your algorithm?
Q4: Shortest-path counting: A chess rook can move horizontally or vertically to any square
in the same row or in the same column of a chessboard. Find the number of shortest paths by
which a rook can move from one corner of a chessboard to the diagonally opposite corner.
The length of a path is measured by the number of squares it passes through, including the
first and the last squares. Solve the problem
a. by a dynamic programming algorithm.
b. by using elementary combinatorics.
Decrease-and-Conquer Technique:
Q5: What is Decrease and Conquer algorithm design technique? Explain these three
variations of this design technique with few examples.
(i) decrease by a constant
(ii) decrease by a constant factor
(iii) variable size decrease
Q6: Ferrying soldiers: A detachment of n soldiers must cross a wide and deep river with no
bridge in sight. They notice two 12-year-old boys playing in a rowboat by the shore. The boat
is so tiny; however, that it can only hold two boys or one soldier. How can the soldiers get
across the river and leave the boys in joint possession of the boat? How many times need the
boat pass from shore to shore?
Q7: Insertion sort is a good example of Decrease-and-Conquer technique. Apply insertion
sort to sort the list E, X, A, M, P, L, E in alphabetical order.
Q8: Can binary search algorithm (performed on any array) be considered as an instance of
Decrease-and-Conquer technique? Explain.
Q9: Consider the following algorithm designed by applying Decrease and Conquer
technique, to check connectivity of a graph defined by its adjacency matrix.
ALGORITHM Connected(A[0..n − 1, 0..n − 1])
//Input: Adjacency matrix A[0..n − 1, 0..n − 1]) of an undirected graph G
//Output: 1 (true) if G is connected and 0 (false) if it is not
if n = 1 return 1 //one-vertex graph is connected by definition
else
if not Connected(A[0..n − 2, 0..n − 2]) return 0
else for j ←0 to n − 2 do
if A[n − 1, j] return 1
return 0
Does this algorithm work correctly for every undirected graph with n > 0 vertices? If you
answer yes, indicate the algorithm’s efficiency class in the worst case; if you answer no,
explain why.

More Related Content

PDF
Answers withexplanations
PDF
Ee693 questionshomework
PDF
Solution 3.
PDF
Ee693 sept2014midsem
PPTX
Computer Science Assignment Help
PPT
5.1 greedy
PPTX
Statistics Assignment Help
PPTX
Signal Processing Assignment Help
Answers withexplanations
Ee693 questionshomework
Solution 3.
Ee693 sept2014midsem
Computer Science Assignment Help
5.1 greedy
Statistics Assignment Help
Signal Processing Assignment Help

What's hot (20)

DOC
algorithm Unit 4
PPTX
Backtracking
PPT
5.1 greedy 03
PPTX
Chemistry Assignment Help
PPTX
Signals Processing Homework Help
PDF
Skiena algorithm 2007 lecture16 introduction to dynamic programming
PPTX
Signal Processing Assignment Help
PPTX
Digital Signal Processing Assignment Help
PDF
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
PPTX
Graph Traversal Algorithms - Depth First Search Traversal
PPTX
Dynamic Programming - Part II
PPTX
Data Analysis Homework Help
PPTX
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
DOC
Unit 3 daa
PDF
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
PPTX
probability assignment help (2)
PPTX
Logistics Management Assignment Help
PPTX
Stochastic Assignment Help
PPTX
Matlab Assignment Help
PPTX
Algorithm Assignment Help
algorithm Unit 4
Backtracking
5.1 greedy 03
Chemistry Assignment Help
Signals Processing Homework Help
Skiena algorithm 2007 lecture16 introduction to dynamic programming
Signal Processing Assignment Help
Digital Signal Processing Assignment Help
ACM ICPC 2013 NEERC (Northeastern European Regional Contest) Problems Review
Graph Traversal Algorithms - Depth First Search Traversal
Dynamic Programming - Part II
Data Analysis Homework Help
ACM ICPC 2012 NEERC (Northeastern European Regional Contest) Problems Review
Unit 3 daa
ACM ICPC 2015 NEERC (Northeastern European Regional Contest) Problems Review
probability assignment help (2)
Logistics Management Assignment Help
Stochastic Assignment Help
Matlab Assignment Help
Algorithm Assignment Help
Ad

Similar to Assignment 2 daa (20)

PPTX
unit-4-dynamic programming
DOCX
Mb0048 operations research
PPTX
Design Algorithms - - Backtracking.pptx
DOCX
Mca 4040 analysis and design of algorithm
DOCX
Mca 4040 analysis and design of algorithm
DOCX
Mca 4040 analysis and design of algorithm
PDF
DOCX
Mit203 analysis and design of algorithms
PDF
pml.pdf
PPTX
Computational Methods in Scientific Programming
PPTX
NP-Completeness - II
DOCX
Bt9301, computer graphics
PDF
Svm map reduce_slides
PDF
Operations Research Project
PPTX
Combinatorial Optimization
PDF
Implementation of D* Path Planning Algorithm with NXT LEGO Mindstorms Kit for...
PPTX
TRAVELING SALESMAN PROBLEM, Divide and Conquer
PPTX
algorithm homework help ppt.pptx
PPT
Analysis of Algorithm
PPT
lec10svm.ppt
unit-4-dynamic programming
Mb0048 operations research
Design Algorithms - - Backtracking.pptx
Mca 4040 analysis and design of algorithm
Mca 4040 analysis and design of algorithm
Mca 4040 analysis and design of algorithm
Mit203 analysis and design of algorithms
pml.pdf
Computational Methods in Scientific Programming
NP-Completeness - II
Bt9301, computer graphics
Svm map reduce_slides
Operations Research Project
Combinatorial Optimization
Implementation of D* Path Planning Algorithm with NXT LEGO Mindstorms Kit for...
TRAVELING SALESMAN PROBLEM, Divide and Conquer
algorithm homework help ppt.pptx
Analysis of Algorithm
lec10svm.ppt
Ad

Recently uploaded (20)

PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPTX
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
PPTX
Fundamentals of Mechanical Engineering.pptx
PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PPTX
Artificial Intelligence
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PDF
Soil Improvement Techniques Note - Rabbi
PDF
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
PPT
Occupational Health and Safety Management System
PPTX
Nature of X-rays, X- Ray Equipment, Fluoroscopy
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
UNIT 4 Total Quality Management .pptx
PDF
86236642-Electric-Loco-Shed.pdf jfkduklg
PDF
Visual Aids for Exploratory Data Analysis.pdf
PDF
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PDF
III.4.1.2_The_Space_Environment.p pdffdf
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
MET 305 2019 SCHEME MODULE 2 COMPLETE.pptx
Fundamentals of Mechanical Engineering.pptx
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
Artificial Intelligence
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
Soil Improvement Techniques Note - Rabbi
Level 2 – IBM Data and AI Fundamentals (1)_v1.1.PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
null (2) bgfbg bfgb bfgb fbfg bfbgf b.pdf
Occupational Health and Safety Management System
Nature of X-rays, X- Ray Equipment, Fluoroscopy
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
UNIT 4 Total Quality Management .pptx
86236642-Electric-Loco-Shed.pdf jfkduklg
Visual Aids for Exploratory Data Analysis.pdf
Analyzing Impact of Pakistan Economic Corridor on Import and Export in Pakist...
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
III.4.1.2_The_Space_Environment.p pdffdf

Assignment 2 daa

  • 1. Assignment: 2 Design & Analysis of algorithm Total marks: 5 This assignment is compulsory for all including roll no 30 and 71. This assignment is to be submitted tomorrow latest by 5 PM. If you fail to submit it tomorrow 3 marks will be deducted. You may submit it on Friday with a penalty of 3 marks. After Friday no submission will be accepted and no marks will be given. From 23rd April no presentation will be held. For remaining students an extra assignment will be given. For tomorrow, three next groups may (not necessary) give presentations (Last presentation). Dynamic Programming Technique: Q1: What does dynamic programming has in common with divide-and-conquer? What is a principal difference between them? Q2: Design an efficient algorithm for computing the binomial coefficient C(n, k) that uses no multiplications. What are the time and space efficiencies of your algorithm? Q3: Rod-cutting problem: Design a dynamic programming algorithm for the following problem. Find the maximum total sale price that can be obtained by cutting a rod of n units long into integer-length pieces if the sale price of a piece i units long is pi for i = 1, 2, . . . , n. What are the time and space efficiencies of your algorithm? Q4: Shortest-path counting: A chess rook can move horizontally or vertically to any square in the same row or in the same column of a chessboard. Find the number of shortest paths by which a rook can move from one corner of a chessboard to the diagonally opposite corner. The length of a path is measured by the number of squares it passes through, including the first and the last squares. Solve the problem a. by a dynamic programming algorithm. b. by using elementary combinatorics. Decrease-and-Conquer Technique: Q5: What is Decrease and Conquer algorithm design technique? Explain these three variations of this design technique with few examples. (i) decrease by a constant (ii) decrease by a constant factor (iii) variable size decrease Q6: Ferrying soldiers: A detachment of n soldiers must cross a wide and deep river with no bridge in sight. They notice two 12-year-old boys playing in a rowboat by the shore. The boat is so tiny; however, that it can only hold two boys or one soldier. How can the soldiers get
  • 2. across the river and leave the boys in joint possession of the boat? How many times need the boat pass from shore to shore? Q7: Insertion sort is a good example of Decrease-and-Conquer technique. Apply insertion sort to sort the list E, X, A, M, P, L, E in alphabetical order. Q8: Can binary search algorithm (performed on any array) be considered as an instance of Decrease-and-Conquer technique? Explain. Q9: Consider the following algorithm designed by applying Decrease and Conquer technique, to check connectivity of a graph defined by its adjacency matrix. ALGORITHM Connected(A[0..n − 1, 0..n − 1]) //Input: Adjacency matrix A[0..n − 1, 0..n − 1]) of an undirected graph G //Output: 1 (true) if G is connected and 0 (false) if it is not if n = 1 return 1 //one-vertex graph is connected by definition else if not Connected(A[0..n − 2, 0..n − 2]) return 0 else for j ←0 to n − 2 do if A[n − 1, j] return 1 return 0 Does this algorithm work correctly for every undirected graph with n > 0 vertices? If you answer yes, indicate the algorithm’s efficiency class in the worst case; if you answer no, explain why.