Return to the Section 101 Homepage.


Discussion 1 (06-21)

Outline

* Administrative Issues / Announcements
* Class Overview
* Homework Help

Administrative Issues / Announcements

Lab Policies

If you want to switch sections, do so on Telebears (or through whatever method you used to enroll); This is the most fair method. If it doesnt work out, you can still switch back to the other section,

We will be more strict on enrollment issues in week two; You may only attend the lab you are registered for.

Somewhere around the end of the second week (or maybe even sooner) we will cancel the account of anyone who is not enrolled (For whatever reason).

You may do the labs on your own time (Either at home or in the lab) and come in just to have them checked off. You may only be checked off in the lab section in which you are enrolled and must be checked off before the end of the section on the day its due. I dont intend to make any special arrangements; You are allowed to drop two lab grades to accomodate special circumstances.

The policies for homework and project submissions are similarly clear. Again, we wont be making any special arrangements, as you have a homework drop and slip days for the projects.

Office Hours

My office hours will be held Tuesdays from 2-3 (Right after this section) and Wednesdays from 10-11, both in 511 Soda.

Newsgroup and Webpage

Please post any course material-related questions to the newsgroup. Not only can your question by answered by either of the TAs or the instructor, but it may also be answered by one of your classmates.

First Week

The first week will be hectic; Thanks for sticking in there.

Class Overview

What is the point of 61B? How can we look at the content of the class? Where does it fit into Computer Science and other fields?

Direct

At the most direct level, we cover Java and the fundamental data structures, including arrays, hash tables, trees, and graphs. We also cover some algorithms for working on those data structures and see how efficiently they run.

Intermediate

At an intermediate level, 61B is a class about problem solving and implementation. That is, turning a problem or requirement or idea into a working program, and hopefully one that runs efficiently and without bugs. Toward this end, we learn a set of tools, including a C-derivative language (Java), programming paradigm concepts and the Object Oriented appraoch, introductory software engineering, and data structures and algorithms.

Conceptual

At perhaps the highest level, this class is about learning to work with conceptual models for organizing ideas. Its also a first step in learning about representation, which allows us to map an idea to a form we are farmiliar with (such as a data structure). We may then use the techniques we have learned for use with those structures to solve the problem.



Its up to you how you want to view the class. Most of the actual work will have you working around levels 1 and 2. But if you are interested, there is a lot of potential for drawing out higher level concepts from this material.

Homework Help (Problem 2)

The homework problem asks you to implement a subtotal calculator using two differnt forms. Here, I have implemented a substring calculator using the same two forms. This is essentially the same thing, but with strings substitued for numbers and concatenation substituted for addition. Here is the code:

SubStringConcatA.java
public class SubStringConcatA {
			
      public static void main(String[] args)
      {
         final String FUNCTION_KEY = new String(".");;
         
         
         
         System.out.println("SubString Concatenation tool.");
         System.out.println("");
         System.out.println("Enter one String per line; enter \'" + FUNCTION_KEY +
                            "\' to indicate the end of a substring group.");
         System.out.println("The program will terminate the second time you enter \'" +
                            FUNCTION_KEY + "\' sequentially.");
         
         
         
         String nextLine = new String("");
         String fullString = new String("");
         String subString = new String("");
         
         // Notice that we use .equals(), which compares the actual characters in each
         //   String, instead of ==, which compares the references to the String's.
         while (!(nextLine.equals(FUNCTION_KEY)))
         {
            while (!(nextLine.equals(FUNCTION_KEY)))
            {
               subString = subString + nextLine;
               nextLine = readNextLine();
            }
            
            System.out.println("Sub String: " + subString);
            fullString = fullString + subString;
            subString = "";
            
            nextLine = readNextLine();
         }
         
         System.out.println("Full String: " + fullString);
      }
      

      
      // This is analogous to nextNumber().
      // Dont modify.
      public static final String readNextLine()
      {
         BufferedReader lineReader =
            new BufferedReader(new InputStreamReader(System.in));
         
         String nextLine = new String("");
         
         try
         {
            nextLine = lineReader.readLine();
         }
         catch (Exception e)
         {
            System.out.println("Problem");
         }
         
         return nextLine;
      }
}

SubStringConcatB.java
import java.io.*;

public class SubStringConcatB {
      
      public static void main(String[] args)
      {
         final String FUNCTION_KEY = new String(".");



         System.out.println("SubString Concatenation tool.");
         System.out.println("");
         System.out.println("Enter one String per line; enter \'" + FUNCTION_KEY +
                            "\' to indicate the end of a substring group.");
         System.out.println("The program will terminate the second time you enter \'" +
                            FUNCTION_KEY + "\' sequentially.");

         
         
         String nextLine = new String("");
         String previousLine = new String("");
         
         String fullString = new String("");
         String subString = new String("");
         


         // Stop only if both the last line and the current line equal the function key.
         // Notice that we use .equals(), which compares the actual characters in each
         //   String instead of ==, which compares the references to the String's.
         while (!(nextLine.equals(FUNCTION_KEY) && previousLine.equals(FUNCTION_KEY)))
         {
            if (nextLine.equals(FUNCTION_KEY))
            {
               System.out.println("Sub String: " + subString);
               fullString = fullString + subString;
               subString = "";
            }
            else
            {
               subString = subString + nextLine;
            }
            
            previousLine = nextLine;
            nextLine = readNextLine();
         }
         
         System.out.println("Full String: " + fullString);
      }
      


      // This is analogous to nextNumber().
      // Dont modify.
      public static final String readNextLine()
      {
         BufferedReader lineReader =
            new BufferedReader(new InputStreamReader(System.in));
         
         String nextLine = new String("");
         
         try
         {
            nextLine = lineReader.readLine();
         }
         catch (Exception e)
         {
            System.out.println("Problem");
         }
         return nextLine;
      }
}

You wont be able to just take this code and convert Strings to ints and turn in the result. I suggest you use this as a real-code example of the loop structures required by the problem.



Return to the Section 101 Homepage.