Tuesday, November 24, 2009

Lab 19

1. Make an array of strings for firstname. Make an array of strings for lastname. Read them from a file. Create a third array of strings for fullname, which is firstname followed by a space followed by a last name.

2. Do the same for C-strings.

3. Again with an array of strings, sort them in ascending order and then print them out. Then sort them in descending order and print them out.

4. The same as above, but sort them based on * string length*.

5. Bubble sort a bunch of numbers.

6. Trace through the recursively insertion sort. In the middle of lab, I will demonstrate the three types of sorts, using iteration rather than recursion. This you don't have to hand it, but it would be a good idea to try it, to make sure you really understand it.

Thursday, November 19, 2009

Lab 18

1. write a function that takes in an array and returns the avg of elements in the array.
2. Write a function that takes in an array and a number n and returns true if n occurs in the array, and false otherwise.
3. Write a function which takes in an array and prints the array in reverse order.
4. Write a function which takes in an array and a number n, and performs swaps of random elements in the array, n times.
5. Write a loop which finds the maximum element of an array.
6. Write a loop which finds the *position* of the maximum element of an array.
7. Go to Wikipedia and look up Selection sort, Insertion Sort, and Bubble. If you can, try to implement these. If not, don't sweat it.

Tuesday, November 17, 2009

Lab 17

1) modify the quiz example to get the values for the arrays from a text file.

2) Work on the array problems which Dr. Ryba gave.
http://venus.cs.qc.edu/~ryba/cs111/Array.pdf

you only need submit your answer to question 1.

Thursday, November 12, 2009

Lab 16

1. Fill a 2d array with 7s
2. Print out that 2d array, with each row on a line, elements separated by ,
3. Given matrices A and B, find C = A + B
4. Given matrices A and B, find C = A - B
5. Calculate the dot product of two 1d arrays.
6. Multiply a 2D array by a scalar
7. Perform Matrix multiplication on 2 matrices.

Tuesday, November 10, 2009

Lab assignment submission

lab 15

1) sum up an array
2) find the product of all elements in an array
3) add one vector to another, to produce a third vector
4) print out a vector
5) fill a vector with elements from the keyboard
6) calculate the standard deviation of a bunch of nums, and print out those scores which are within one standard deviation of the mean.
7) using an array, print out a number in reverse order.

Tuesday, November 3, 2009

Lab 14

1. write a recursive function that asks for numbers (ending when the user types in a -1), and will print it in reverse order.

2. Use the STL stack data type, and use it to reverse a bunch of numbers, just as above.

3. Find the sum of the numbers 1 through 10, using recursion.

4. Write exp(x, n), and returns x ^ n;