You are on page 1of 1

Design and Analysis of Algorithms 251.

Sri Lanka Institute of Information Technology.


Assignment.
Due Date: 14th of September 2010

1. A partition of a positive integer n is a sequence of positive integers that sum to n.


Write an algorithm in psedocode and then implement the algorithm (in C) to print
all non-increasing partitions of n.
eg. If n=4 4
3 1
2 2
2 1 1
1 1 1 1
2. First write an algorithm in psedocode and then Implement (in C) an algorithm that
computes the number of 1's in the binary representation of a non-negative integer
n . For example if n = 15 your program should return 4 since the binary
representation of 15 is 1111. The program should be a recursive one, based on the
following definition of f(n) , the number of 1's in the binary representation of n :
f(n) = f((n-1)/2) + 1 if n is odd

= f(n/2) if n is even

Instruction for submission and demonstration


You should include:
1. A printout of all source code for the programs with proper in-line documentation.
2. Description for any cases for which your program is not working correctly.
3. Sample inputs and outputs from your running programs.
Your submission must have a cover page, which must include:
1. The words “Design and Analysis of Algorithms 214”.
2. Your name and DIT number.
3. A signed statement that the assignment is your own work.
3. Put all your source code in directory with your DIT number. The soft-copy of your
assignments should be uploaded to the course web on the specified due date for the
assignment. Late assignments will not be accepted.
4. Due dates and other arrangements may only be altered with the consent of the majority
of the students enrolled in the unit and with the consent of the lecturer.
5. Demonstration requirements:
1. You may be required demonstrate your working program and/or sitting in a quiz
during practical sessions.
2. The source code MUST be that submitted.
3. The programs should run on the department’s machines.

Failure to meet the above-mentioned requirements will result in the fail the subject.

Design and Analysis of Algorithms 214 Assignment.

You might also like