CIS 114                                                     Summer 2005


                            Homework 1
			    ----------

- General Instructions (GI) for all Homeworks:

1 Please submit answers to the following questions by email,
  to geller@njit.edu.

2 Send a separate message for each question of each homework.

3 Write a subject line containing "CIS 114" and the number of the homework and
  the number of the question.  Thus your first message to me should have 
  this subject: CIS 114, HW 1, Q 1.
  (I get a lot of email every day.  Many messages don't get noticed till
  two weeks later.  Only if you write the subject line as described will
  I read your message immediately.)

4 SEND AN ASCII MESSAGE.  That means, send plain text. ******************
  Do NOT send a Microsoft Word document.  I am expecting to receive
  about 800 homework messages, and I need to decode your message if it
  is in Word, which is a lot of additional work for me.  If you are using
  MS Word, then save files as Text Only with Linebreaks.

  Do NOT send a file that is encoded in any way. (I.e. Zipped or MIMED).
  In other words, don't send your text as attachment, just send it in the
  message body.  If necessary, cut and paste it into the message body.
  Note that if you are using PINE, messages tend to get MIME encoded,
  which again would cause me additional decoding work.  Please be considerate.

  Do not send messages that are in HTML only.  Web mail systems let you
  chose different options: Text only, Text and HTML, or HTML only.
  I prefer Text only.

5 Make sure you observe the due dates.  Once I've graded a homework
  I will not accept late homeworks except with written documentation
  of a major medical problem.

6 First view the tapes, then try to answer the questions.  If you can't
  answer, check the book or check the online notes.  If that does not help,
  you might have to watch the tapes again.  

7 Questions will be worth 5 poins.

8 Content and Form:  When I am grading I am looking for content AND form.
  That means, I ask you to be careful to avoid obvious mistakes and spelling
  errors.  For obvious mistakes it really helps to reread your answer one
  more time before you send the homework out.  For spelling there are spelling
  checkers.

9 Best effort:  Some of the questions will not have a clear or simple answer,
  but they will require thinking.  In all those cases I assure you that I will
  grade *generously*.  Thus, if you make a best effort you will receive full
  credit.  In general, if you put a fair amount of work into your answers
  you will receive good grades.

10 Don't go overboard.  In general I will not give questions that require
   answers longer than 24 lines.  (One old-fashioned screen.)  Most answers
   will fit into one paragraph.  Thus, if your initial answer comes out
   to be quite long, please review it to see if you can extract the
   essential parts and send me only those essential parts.  Remember, again,
   I am going to get at least 140 answers A WEEK.  Answers that are too
   long (unnecessarily) will not make me happy. :)

11 You may NOT cooperate with other students unless I specifically
   say that in the assignment.  See the Syllabus about this.
           

-----
If you are making mistakes...
If I ever send you am email message such as 'GI 3' that means you
did not follow General Instruction number 3 listed above.  That means,
your message had no subject, or an incomplete subject.

In most of those cases I will ask you to resubmit your message correctly.
-----

Corrections to Notes:

In some cases the notes on the web are outdated or contain mistakes.
If such a mistake affects a homework, I will note this in the homework
assignment itself.

-----
After all this introduction, here are finally the questions:
One question per tape:

THIS HOMEWORK IS DUE WEDNESDAY JUNE 1ST AT 6:00 PM.

Q 1:  Explain in one paragraph which C++ you are using, and how to
      edit/compile/run a C++ program in your environment.  (I.e., what
      menu options or what commands you need for editing/compiling/running).
      [This answer could fit onto 4 lines.]

Q 2:  Write a C++ program that reads in two numbers from the keyboard and
      writes the sum of the decrements of them to the screen.  
      (E.g.: If the input numbers are 4 and 5, your program should write
      7 to the screen, because the decrements of 4 and 5 are 3 and 4.
      3 + 4 = 7).  Use the appropriate C++ operators to do that.
      Compile, run, debug, and document the program.  Send me the C++ source.

Q 3:  (a) Show a C++ example how to initialize an integer variable Y.
      (b) Show a C++ example how to initialize a character variable Y.
      (c) Show a C++ example how to initialize an array of characters Y with
	  6 elements.
      (d) Show a C++ example how to initialize an array of integers Y with
	  6 elements.
      Do not hand in code with syntax errors.  But do not write
      any explanations either.
    

Q 4:  Recursion is quite difficult for many people.  You need to spend
      a fair amount of time, understanding exactly how parameters are 
      passed, and even more how values are returned.
      If you call "factorial(5)" write down for every recursive call
      what will be passed as parameter and what will be returned.
      Follows this format:

      factorial(5)  calls: ........    returns: ..........
      factorial(...) calls:   etc.

Q 5:  What is the value of fib(5)?  Compute it by hand, but 
      RECURSIVELY.  Your solution needs to contain one line only.

Q 6:  Binary search is OUTSTANDINGLY IMPORTANT.  Make every effort to
      understand it.  In the lecture I explain how to search a phone
      book by hand with binary search.  Explain in your own words.
      One paragraph.  Good English.