## CSci 3501 Algorithms and Computability - Lab 1.

#### September 2. Due Monday, September 8 at 10:30

What to submit and when:

- All submissions are electronic: by e-mail to elenam at morris.umn.edu and CC to all lab partners. Please do not delete your e-mail from "Sent mail" or your mailbox until the end of the semester.
- When working on the lab, please comment your work so that it is clear what contributions of each person are.
- At the end of the lab each group should send me the results of their
in-class work. Please indicate if this is your final submission.
- If your submission at the end of the lab time was not final, please send me(CC to the lab partner(s)) a final copy before the due time. Please use the subject "3501 Lab N", where N is the lab number.

#### Lab assignment

Work in pairs.

Design and implement an algorithm for finding all combinations of the first n integers.

Input: n.

Output: all possible combinations of numbers from 1 to n written one combination per line without repetitions (in any order).

Example: input: n = 3. Output:

```
1 2 3
1 3 2
2 1 3
2 3 1
3 1 2
3 2 1
```

Time your program using Java time function (time in milliseconds):

```
long time = System.currentTimeMillis();
```

gives you the current time in milliseconds. Measure it before and after printing the output, subtract the two numbers, and print the result.

What is the running time of your algorithm in the number of printed lines? Give your answer as Big-O, explain how you computed it.

Based on your timing results and on the Big-O approximation please estimate how long your program runs for n = 15 and for n = 20. Show how you computed the estimate.

This page is a part of CSci 3501
course web site.

The views and opinions expressed in this page are strictly those of the page author. The contents of this page have not been reviewed or approved by the University of Minnesota.