< Back

Test 2


$ mkdir ~/cs170/tests
$ mkdir ~/cs170/tests/test2
$ cd ~/cs170/test/test2

This portion of the test is worth 29 total points. In addition to this file, you may only access the Python documentation website and the Qt documentation documentation website. NO OTHER WEBSITES ARE PERMITTED. You are also not allowed to access any personal files in your CS account. As usual, you are not allowed to directly copy any code from the Internet or another individual. You should also follow all coding standards discussed thus far.


Test 2

Make sure you place these new QT projects in your test 2 directory!


Question 8

Create a QT class which has two text inputs on the page. It should allow the user to type information into both of these text input fields, and press a button. If the text entered into each field is the same, you should put the word "Valid" somewhere on the QT window. If the text entered is not the same, you should put the word "Invalid."

(10 points)


Question 9

Create a QT class which displays an 8 x 8 grid of colored squares on the QT window. The squares should be arranged in a checkerboard fashion.

(10 points)

 


Question 10

In a file called sorted.cc, write a function bool bubble(int * array, int size). This function should sort IN PLACE the specified array using the bubble sort algorithm.

(9 points)


 

Challenge

Pigeonhole sort is a unique sorting algorithm, since it does not compare any elements to produce a sorted output. Instead, Pigeonhole sort relies on knowing something additional about the input: The range of values.

Pigeonhole sort creates an array of counters (each initially set to 0). Each position in this "bucket" array is associated with some element from the range of values stored in the array to be sorted. As you iterate through the array to be sorted, you will simply increment the corresponding counter for that value. After you have computed the counts for all of the values, you simply need to go through the "bucket" list, and place the correct number of values (bucket indicies) into the array to be sorted.

In a file called bonus.cc, implement a function called void pigeonhole(int * array, int size). This function should follow the steps of the pigeonhole sort in order to sort the entire array IN PLACE.

(5 points)

 


Submission

When you have finished, create a tar file of your test1 directory. To create a tar file, execute the following commands:

cd ~/cs170/tests
tar czvf test2.tgz test2/

To submit your activity, go to inquire.roanoke.edu. You should see an available assignment called Test 2. Make sure you include a header listing the authors of the file.