CS 2213/2211
 Advanced Programming
 Spring 2005

 Recitation 5:  Pointers and Arrays
    Week 5: Feb 15-17
 Due (on time): 2005-02-22  23:59:59
 Due (late):        2005-02-27  23:59:59

Recitation 5 should be submitted following directions at: submissions with deadlines
  • 2005-02-22  23:59:59 (that's Tuesday, 22 February 2005, 11:59:59 pm) for full credit.
  • 2005-02-27  23:59:59 (that's Sunday, 27 February 2005, 11:59:59 pm) for 75% credit.


Introduction: This recitation works on two areas:

For this recitation you must:

  1. Work with the C program at the left in the listing: Bubblesort Programs. (Here is the source: bubblesort.c.)

  2. Transform this program from array index notation to pointer notation. You can tell if you are doing this if the program works and there are no occurrences of the square brackets '[' or ']' in the program. You can use the listing Indexes versus Pointers.

  3. Add to the C program so that it takes the size of the array to be sorted from the command line, as the Java program on the left does. Refer to the program clarg.c in the writeup for Recitation 4.

  4. Fix up this part also so that there are no occurrences of the square brackets '[' or ']'. [Hints: a prototype for main can be written in the form:

    as we will discuss shortly. As for the occurrence of argv[1], convert this the same way you would convert a simple reference to a[1] in an array declared int a[5]. You should each figure out how to do this on your own, without help from other students.]

  5. Carry out 3 runs of the program, with 100, 1000, and 10000 on the command line.


What you should submit: Refer to the submissions directions and to deadlines at the top of this page. The text file that you submit should first have Your Name, the Course Number, and the Recitation Number. The rest of the file should have the following in it, in the order below, and clearly labeled, including at the beginning the appropriate item letters: a, b, c, etc.

 Contents of email submission for Recitation 1:

Last Name, First Name; Course Number; Recitation Number.

a. Source listing for the rewritten program bubblesort.c.

b. Three runs of this program with 100, 1000, and 10000 on the command line. You should print the array only for the first run of size 100.

c. Give the expected "Big-Oh" performance of a bubblesort algorithm, and show that the results of the three runs above are consistent with this performance. (This gives how fast the algorithm is expected to run as a function of the size of the data being processed -- in this case an array of size n.)


Revision date: 2005-02-16. (Please use ISO 8601, the International Standard.)
Copyright © 2011, Neal R. Wagner. Permission is granted to access, download, share, and distribute, as long as this notice remains.