Problem Set 1
Due: February 4, 2008. 1. In the bin packing problem, the input consists of a sequence of items I = {1, . . . , n} where each item i has a size, which is a real number 0 ≤ ai ≤ 1. The goal is to “pack” the items in the smallest possible number of bins of unit size. Formally, the items should be partitioned in disjoint subsets (bins), such that the total size in each bin is at most 1. The ﬁrst ﬁt heuristic scans the items one by one, and each item is assigned to the ﬁrst bin that it can ﬁt in. Prove that ﬁrst-ﬁt is a 2-approximation algorithm for bin packing. Hint. Bound from below the number of bins used by an optimal solution; and bound from above the number of bins used by ﬁrst ﬁt, using the observation that nearly all bins are at least half-full. 2. Suppose now that you want to pack as much as possible in a single bin. Formally, the input consists of a set of items I = {1, . . . , n}, where each item i has a size 0 < ai ≤ 1. A solution is a set of items S ⊂ I such that i∈S ai ≤ 1 (i.e., the size of the bag is 1). The value of a solution S is the total size of the items in the solution, i.e., i∈S ai . (a) Describe an optimal solution to the problem. What is the time complexity of your algorithm? (b) Give a polynomial-time algorithm with approximation ratio 2 (i.e., it guarantees that you ﬁll at least half of the optimal value). What is the time complexity of your algorithm? Warning. The simplest solution doesn’t work! 3. Consider the following algorithm for the m-machine load-balancing problem (S is the set of jobs): Repeat: (a) Let A be the sum of weights of all jobs in S (b) Find a subset S1 ⊆ S whose sum of weights is close to A/m (c) S ← S \ S1 ; m ← m − 1 until m = 0. Suppose that the subset sum step above is implemented using an approximation algorithm, which guarantees that its result is within a factor of 1 − ǫ from the optimal subset sum, for some 0 < ǫ < 1. What can you...

...MC0080-Analysis and Design of Algorithms
Question 1- Describe the following:
Well known Sorting Algorithms
Divide and Conquer Techniques
Answer:
Well known Sorting Algorithms
We know the following well - known algorithms for sorting a given list of numbers:
Ordered set: Any set S with a relation, say, ≤ , is said to be ordered if for any two elements x and y of S, either x ≤ y or x ≥ y is true. Then, we may also say that (S, ≤) is an ordered set.
1. Insertion sort
The insertion sort, algorithm for sorting a list L of n numbers represented by an array A [ 1… n] proceeds by picking up the numbers in the array from left one by one and each newly picked up number is placed at its relative position, w.r.t. the sorting order, among the earlier ordered ones. The process is repeated till each element of the list is placed at its correct relative position.
2. Bubble sort
The Bubble Sort algorithm for sorting of n numbers, represented by an array A [1..n], proceeds by scanning the array from left to right. At each stage, compares adjacent pairs of numbers at positions A[i] and
A [i +1] and whenever a pair of adjacent numbers is found to be out of order, then the positions of the numbers are exchanged. The algorithm repeats the process for numbers at positions A [i+1] and A [i + 2]
3. Selection sort
Selection Sort for sorting a list L of...

...Question 1
In what follows we consider two simple algorithms for the Knapsack problem. We assume without
loss of generality, that for every object i we have si B (or else we can remove the object from the
set of objects).
Item A. Consider the following greedy algorithm for the knapsack problem: For each object i,
compute the “profit-to-size” ratio ri = pi/si. We order the objects according to ri, from big to small,
and then go over the objects in this order and add an object if it doesn’t violate the size constraint
(that is, the total size of the selected objects is at most B). Show that the approximation factor this
algorithm gives may grow (at least) linearly with B (so that in particular it is not any fixed constant
or even a function of the number of objects).
Item B. We modify the algorithm in the previous item as follows. We still order the objects according
to the ri’s. We then find the minimal k such that the total size of the first k objects according to this
order exceeds B. The algorithm now compares the total profit of the first k − 1 objects to the profit
of object k and takes the better of the two. Show that this algorithm gives an approximation factor
of 2.
Question 2
As mentioned in class, there is a more “natural” pseudo-polynomial algorithm for solving the Knapsack
problem using a dynamic programming approach. Specifically, for each 1 i...

...TK3043 : Analysis and Design of Algorithms
Assignment 3
1. Compute the following sums:
a. ∑
Answer:
=∑
=u–1+1
= (n + 1) – 3 + 1
=n+1–2
=n-2
b. ∑
Answer:
=∑
= [1 + 2] + … + n
=∑
+ (n + 1) – (1 + 2)
=∑
+ (n + 1) – 3
=∑
+n –2
= n(n + 1) + (n - 2)
2
= n2 + n + (n - 2)
2
= n2 + 3n – 4
2
c. ∑
Answer:
∑
=∑
=∑
= n (n+1) (2n + 1) + n (n+1)
6
2
= (n - 1) (n -1 + 1) (2 ( n –1) +1) + (n - 1) (n – 1 + 1)
6
2
= (n - 1) (n) (2n – 2 + 1) + (n – 1) (n)
6
2
2
= (n - n) (2n – 1) + (n – 1) (n)
6
2
= (n3 - n2 - 2n2 + n) + (n2 – n)
6
2
= 2n3 - 3n2 + n + n2 – n
6
2
= 2n3 - 3n2 + n + 3n3 – 3n
6
= 2n3 – 2n
6
= n3 – n
3
2
=n –1
3
2. Consider the following algorithm.
Algorithm Mystery( n)
//Input: A nonnegative integer n
S←0
for i ← 1 to n do
S←S+i*i
return S
a. What does this algorithm compute?
Answer:
2
S(n) = ∑
b. What is its basic operation?
Answer:
Multiplication
c. How many times is the basic operation executed?
Answer:
At least one time
d. What is the efficiency class of this algorithm?
Answer:
C(n) = n (n)
e. Suggest an improvement or a better algorithm altogether and indicate its efficiency
class. If you cannot do it, try to prove that, in fact, it cannot be done.
Answer:
∑
2
= n (n + 1) (2n + 1)
6
3. Consider the following algorithm.
Algorithm...

...AlgorithmAnalysis and Design NP-Completeness
Pham Quang Dung
Hanoi, 2012
Pham Quang Dung ()
AlgorithmAnalysis and Design NP-Completeness
Hanoi, 2012
1 / 31
Outline
1
Easy problems - class P Decision problems vs. Optimization problems Class NP Reductions NP-complete class
2
3
4
5
Pham Quang Dung ()
AlgorithmAnalysis andDesign NP-Completeness
Hanoi, 2012
2 / 31
Class P: Problems that are solvable by polynomial-time algorithms (O(nk ) where n is the size of the input to the problem and k is some constant) Examples:
Sorting Shortest path problems Minimum Spanning Tree problems Maximum Flow problems ...
Pham Quang Dung ()
AlgorithmAnalysis and Design NP-Completeness
Hanoi, 2012
3 / 31
Outline
1
Easy problems - class P Decision problems vs. Optimization problems Class NP Reductions NP-complete class
2
3
4
5
Pham Quang Dung ()
AlgorithmAnalysis and Design NP-Completeness
Hanoi, 2012
4 / 31
Decision problems
Answer is “yes” or “no”
Is n a prime number? Does an undirected graph contain a hamilton cycle? Satisﬁability: Given a boolean formula. Does there exist some assignment of the values 0 and 1 to its variables such that the value of the formula...

...University Ave. Sangandaan, Caloocan City
-------------------------------------------------
ANALYSIS OF ALGORITHMS AND ORDERS OF GROWTH
In Partial Fulfillment Of the requirements for the Degree
Bachelor of Science in Information Technology
School year 2011-2012
-------------------------------------------------
Submitted By:
Dacutanan, Francis III C.
Submitted to:
Engr. Nelson Rodelas
Chapter I
Introduction
Algorithms are one of the few mathematical and logical constructs whose theoretical concept is being provided to represent for an instance in practical application by billions of people each day via the computer. Understanding the historical background, formulation, analysis and searching methods regarding algorithms is useful for those in the computer science field and curious outsiders including the other researchers upon studying in gaining an appreciation for what a computer can do as well as its limitations. Algorithms are expressed in a variety of ways; most commonly is natural languages, which are spoken languages. The other way that they are commonly expressed is through artificial languages such as mathematics and programming languages. They are also expressed, for learning purposes using flowcharts to illustrate the algorithmic concepts in academic settings understudy by many other researchers within this era of Information Technology.
Searching...

...STA 600
ASSIGNMENT 2
CHAPTER 3: DIAGNOSTICS AND REMEDIAL MEASURES
Diagnostic For Predicted Variable
Probems can occur when:
* Outliers exist among X levels
* X levels are associated with run order when experiment is run sequentially
Useful plots of X levels:
* Dot plot for discrete data
* Histogram /stem-and-leaf plot
* Box plot
* Sequence plot (versus time order)
Departures From Model To Be Studied By Residual
1. The regression function is not linear.
2. The error terms do not have constant variance.
3. The error terms are not independent.
4. The model fits all but one or few outliers,
5. The error terms are not normally distributed.
6. One or several important predictor(s) have been omitted from the model.
Diagnostic For Residuals
Six diagnostic plots to judge departure from the simple linear regression model
* Plot of residuals against predictor variable. (The plot should have a random scatter of plots)
* Plot of absolute or squared residuals against X.
* Plot of residuals against the fitted values.
* Plot of residuals against time or other sequence. (Should not display any trends)
* Plots of residuals against omitted predictor variables.
* Box plot of residuals.
* Normal probability plot of residuals. (Should lie along a straight line)
EXAMPLE
Predictor
Good Looking Plots
Figure: Normal probability plot...

...Lecture Notes on Design & Analysis of Algorithms
G P Raja Sekhar Department of Mathematics I I T Kharagpur
Acknowledgements : Ahmad Abdullah, Pronoy Sikdar, Anshul Kamra, Sugam Agrawal & Students of DAA course 2006-07, Data Structures & Algorithms 2006-07.
BUBBLE SORT
The bubble sort is the oldest and simplest sort in use. The bubble sort works by comparing each item in the list with the item next to it, and swapping them if required. The algorithm repeats this process until it makes a pass all the way through the list without swapping any items. This causes larger values to "bubble" to the end of the list while smaller values "sink" towards the beginning of the list.
Pros: 1) Simplicity and ease of implementation. 2) Auxiliary Space used is O (1). Cons: 1) Very inefficient. General complexity is O (n2). Best case complexity is O(n).
Bubble Sort Efficiency
INSERTION SORT
The insertion sort works just like its name suggests - it inserts each item into its proper place in the final list. The simplest implementation of this requires two list structures - the source list and the list into which sorted items are inserted. To save memory, most implementations use an in-place sort that works by moving the current item past the already sorted items and repeatedly swapping it with the preceding item until it is in place.
Pros: Auxiliary space used is O (1). Cons: General Complexity is O...

3413 Words |
11 Pages

Share this Document

{"hostname":"studymode.com","essaysImgCdnUrl":"\/\/images-study.netdna-ssl.com\/pi\/","useDefaultThumbs":true,"defaultThumbImgs":["\/\/stm-study.netdna-ssl.com\/stm\/images\/placeholders\/default_paper_1.png","\/\/stm-study.netdna-ssl.com\/stm\/images\/placeholders\/default_paper_2.png","\/\/stm-study.netdna-ssl.com\/stm\/images\/placeholders\/default_paper_3.png","\/\/stm-study.netdna-ssl.com\/stm\/images\/placeholders\/default_paper_4.png","\/\/stm-study.netdna-ssl.com\/stm\/images\/placeholders\/default_paper_5.png"],"thumb_default_size":"160x220","thumb_ac_size":"80x110","isPayOrJoin":false,"essayUpload":false,"site_id":1,"autoComplete":false,"isPremiumCountry":false,"userCountryCode":"US","logPixelPath":"\/\/www.smhpix.com\/pixel.gif","tracking_url":"\/\/www.smhpix.com\/pixel.gif","cookies":{"unlimitedBanner":"off"},"essay":{"essayId":36630442,"categoryName":"Periodicals","categoryParentId":"17","currentPage":1,"format":"text","pageMeta":{"text":{"startPage":1,"endPage":3,"pageRange":"1-3","totalPages":3}},"access":"premium","title":"Design and Analysis of Algorithms","additionalIds":[7,93,2,5],"additional":["Education","Education\/Greek System","Awards \u0026 Events","Computer Science"],"loadedPages":{"html":[],"text":[1,2,3]}},"user":null,"canonicalUrl":"http:\/\/www.studymode.com\/essays\/Design-And-Analysis-Of-Algorithms-1285446.html","pagesPerLoad":50,"userType":"member_guest","ct":10,"ndocs":"1,500,000","pdocs":"6,000","cc":"10_PERCENT_1MO_AND_6MO","signUpUrl":"https:\/\/www.studymode.com\/signup\/","joinUrl":"https:\/\/www.studymode.com\/join","payPlanUrl":"\/checkout\/pay","upgradeUrl":"\/checkout\/upgrade","freeTrialUrl":"https:\/\/www.studymode.com\/signup\/?redirectUrl=https%3A%2F%2Fwww.studymode.com%2Fcheckout%2Fpay%2Ffree-trial\u0026bypassPaymentPage=1","showModal":"get-access","showModalUrl":"https:\/\/www.studymode.com\/signup\/?redirectUrl=https%3A%2F%2Fwww.studymode.com%2Fjoin","joinFreeUrl":"\/essays\/?newuser=1","siteId":1,"facebook":{"clientId":"306058689489023","version":"v2.8","language":"en_US"}}