UCR CS 14: Introduction to Data Structures and Algorithms

Spring Quarter 2003 / Class webpage




FAQ

1. Do I have to read the book?
You definitely should read it! The book would not be *required* if you were not expected to read it. Reading as studying method is essential. Try to be as up to date to the lecture topics as possible. Once you fall behind, it is very difficult to come back to track again. The lecture goes in a very fast pace, and you will need to read the book to get all the details that were not clear during the lecture.

2a. Which topics may appear in the quiz/midterm/finals?
2b. What should I study?

Everything that was covered during the lectures, labs, and homework assignments. Go through the book chapters that were covered in lecture and you will find what is most likely to appear in the exams.

3. How should I study?
There is no recipe for this, just some suggestions. A really good one is to consider the lecture notes as guideline, and read the chapters in the book that cover the lecture notes topics. There are two simple reasons for this suggestion: it is impossible to show everything in the slides due to space limitations, and you should go through the code samples that the book presents. For example, sorting algorithms: the lecture notes present the basic idea, and the book presents the code in details. Finally, in this case you should also try to implement the algorithms by yourself and see what happens. Another precious suggestion: if you have access to the exams that were given in the previous quarters, you should go through them as well. Some issues are so important that they will be in every single quiz/midterm/final of any quarter.

Consider going to your TA’s office hours and also the professor office hours. They are there to help you understand the material, and the office hours mean that they set aside some time exclusively to help the students in an individual manner, to address your specific question.

4. Why should I go to the lab section and stay there for 3 hours?
There is only one efficient way of learning programming: coding/debugging/coding/debugging. Programming is a skill like dancing. Even though you know all theory about it, you will dance only if you practice it. So, let’s use the whole 3 hours just for practicing the skill of programming.

"Programming is a skill, and like most skills, it is not something you simply read about and then execute. Learning to program is like learning to speak a foreign language; it’s a long process requiring much work. Even for the gifted and motivated, it takes years of effort to become a top-notch programmer. On the other hand, the rewards can be substantial. The demand for talented programmers seems inexhaustible, so becoming one leads to ample employment opportunities and healthy salaries. In addition, many find programming to be a creative, deeply satisfying endeavor. Consider constructing an elegant solution to an intricate problem, such as finishing the blueprint of a cathedral, and then bringing it to life in running code." Beyond The Basics, Smart Computing, December 1999, Vol.10, Issue 12. (http://www.smartcomputing.com)

5. Why should I go to the lecturer/TAs office hours?
If you need help, you definitely should go. So far, we can not guess whether you need help or not. You have to ask for help and (please!) do not be ashamed/shy/afraid of coming to our office hours. One definition for the word university is: “an institution of higher learning providing facilities for teaching and research and authorized to grant academic degrees” (from the Merriam-Webster OnLine). Guess what? We are the ones responsible for teaching you, so there is no problem in coming to our office hours whenever you have a question or want to discuss in detail some topic that was presented in class.

6a. Why should I write comments in my programming assignments?
6b. Why should I give highly descriptive names to functions and variables?

Commenting code is essential to understanding. Your TA needs to look at your code and understand what you are doing before he/she tries to help you. If you don’t comment your code, it is very possible that YOU won’t understand it once you try to study for the midterms. And in the future, you will never code a whole system from the ground up alone. You will collaborate with other programmers, and exchange code. You want your code to be as clear as possible to your fellow. It is better to get used to commenting as soon as possible. You don’t have to comment every single line, but make an effort to comment every function, every major block in your code and every place where you write some "trick" in your code. By the way, naming variables and functions with descriptive names make the burden of commenting lighter.

For example, take a look at these two codes. You have 10 seconds to tell what the first one does.

CODE 1

void  bs (DataType a[], int n)
{
   bool s = false;
   for (int p = 1; (p < n) && !s; ++p)
   {
      s = true;
      for (int i = 0; (i < n-p) && !s; ++i)
      {
         int ni = i + 1;
         if (a[i] > a[ni])
         {
            sp (a[i], a[ni]);
            s = false;
         }
      }
   }
}

Now you have the same 10 seconds to tell what this second code does.

CODE 2

void  bubbleSort (DataType theArray[], int n)
// Sorts the items in an array into ascending order.
// Precondition: theArray is an array of n items
// Postcondition: theArray is sorted into ascending order; n is unchanged
{
   bool sorted = false;	// false when swaps occur
   for (int pass = 1; (pass < n) && !sorted; ++ pass)
   {  
      // Invariant: theArray[n+1-pass..n-1] is sorted
      //     and > theArray[0..n-pass]
      sorted = true; // assume sorted
      for (int index = 0; (index < n- pass) && !sorted; ++i)
      {  
         // Invariant: theArray[0..index-1] <= the Array[index]
         int nextIndex = index + 1;
         if (theArray[index] > theArray[nextIndex])
         {  
            // exchange items
            swap (theArray[index], theArray[nextIndex]);
            sorted = false;	// signal exchange
         } // end if
      } // end for
   // Assertion: theArray[0..n-pass-1] < theArray[n-pass]
   } // end for
}// end bubblesort

7. Why should I care about the class topics?
A good understanding of the basic data structures is essential in every course that will follow in your career, regardless of the specific area in computer science that you want to focus on. Whether you want to work on computer graphics, artificial intelligence, computer networks, operating systems, you name it. You will find data structures and its main algorithms to be an essential knowledge. Besides, look through the following CS courses pre-requisites (note that you need at least C- in CS14 to take CS141, and you need CS141 for a considerable part of the upper division courses):