Lab 4
28-1-2002 to 31-1-2002

1. Write a class called BubbleSort with a method bubbleSort which bubble sorts a sequence of Student objects as follows:
generate a random sequence of Student objects with hall number between 1 and 7 (Note: nextInt(n) in class Random generates a random integer betwee 0 and n-1 (not n)), and a roll number between 0 and 999 (so the type of roll number is int and not String). Note that roll number must be unique, so no two students can have the same roll number. Now sort the sequence such that the ordering is by increasing hall number and for the same hall number by increasing roll number. Generate enough students so that there are at least a few in each hall. You cannot use an extra array while sorting.

[10]

2. We wish to generate the following sequences from the digits 1, 2 and 3, that consist of pairs of different adjoining non empty sequences. So some allowed or good sequences are:
        1
        12
        1213
        12312
        3212321
        etc.
while here are some disallowed or bad sequences:
        11
        1212
        32132132
        etc.
The problem is: given that there is at least one good sequence of size 100 digits write a program which will generate the list of all good sequences in increasing/alphabetical order up to and including the first sequence of size 100. The ordering is the obvious one where 1<2<3 and the sequences are ordered by length - so if we treat any particular sequence as a number then it is by numerical magnitude.
Hints: 1) Stepwise refinement. 2) A bad sequence cannot be extended to a good one but a good sequence is of size one or obtained by extending a good sequence by a single digit.

[15]