CS 130 Computing Concepts -- Spring 2011


How to prepare for the exam

  1. Reread the Ruby text
  2. Redo the labs
  3. Make sure you can answer the sample questions below
  4. Get plenty of sleep the night before (it's hard to think when you are overtired).
  5. Make sure you can answer the questions on the first review sheet!

NB:

  1. Not all these questions will appear on the exam.
  2. Not all the questions on the exam appear here.

Sample questions:

  1. Describe the stepwise refinement technique.
  2. Describe the ABC technique.
  3. Why does drawing a picture help (in the context of problem-solving)?
  4. What is the definition of an algorithm?
  5. Why can't the steps in an algorithm require judgment?
  6. How many cases must Ruby handle to find the next crumb (assuming no gaps)?
  7. How many cases must Ruby handle to find the next crumb (assuming gaps)?
  8. What are the six steps in programming?
  9. What are varibles used for? If you have no idea, you might want to read this.
  10. What are the two types of variables we have used?
  11. Declare a varible named foo, of type int.
  12. Declare a variable named s, of type String.
  13. Store 17 in foo.
  14. Store "17" in s.
  15. What is the MyReader class used for?
  16. What are the two MyReader messages you must use to read a file?
  17. What are the two messages you send to TextFields?
  18. What are events in Java?
  19. How to you get NetBeans to write actionPerformed for a Button you have in the Form Designer?
  20. How do you convert a String to an int?
  21. How to you convert an int to a String?
  22. What is the value (in decimal) of the following binary numbers? 0, 1, 101, 1001, 10101, 110, 111, 10000000
  23. What are the following numbers written in binary? 1, 10, 2, 4, 8, 17, 255
  24. What's wrong with this code? How could you fix it?
    while (!frontIsBlocked()) {
        if (nextToACoin()) {
            takeCoin();
        }
    }
                    
  25. What's wrong with this code? How could you fix it?
    while (!nextToACoin()) {
        takeCoin();
    }
                    
  26. What's wrong with this code? It is supposed to take a coin and turn left if it is next to a coin. How could you fix it?
    if (nextToACoin())
        takeCoin();
        turnLeft();
    
                    

Programming questions:

Please write beautiful code! No long, complicated methods. Good names. Nice layout.
  1. Arithmetic! Ruby starts at home with no coins. There is a pile of coins at home, and another just north of home. Ruby's task is to subtract as many coins as are in the north pile from the pile at home. Assume there are more at home than north. To finish, go home, face east, and halt.
  2. Write a complete instruction to double the number of coins at home. Assume she starts will more coins in her bag than she will need.
  3. Write a complete instruction to multiply the number of coins at home by 32.
  4. Assume there is a binary number written in coins (as in class) with the most significant bit at home, the next most significant digit to the east of that... So, one coin means 1, no coin means 0. To mark the end of the number there are 2 coins. Write a complete instruction to find the 2 coins (assume Ruby starts at home).
  5. Write a complete instruction to make Ruby face east if she is standing by more coins than are in her bag, or west otherwise.
  6. Write a complete instruction to move all the coins in a stack one block east. Assume Ruby starts at home and the stack is somewhere in front of her.
  7. Squares. Initial situation: Ruby is at home with N coins in her bag and 1000 coins one block north. Final situation: Ruby is home at the corner of an NxN square (one coin per intersection).