Sections
Each week you will complete problem(s) to turn in at your section. Most weeks there will usually be problems posted for both Tuesday's and Thursday's section. You must complete at least one problem set per week to earn +3 points for that week. You must earn a total of 20 points for the quarter to receive full credit. Additional points beyond these 20 do not affect your grade, but you are welcome to complete every set of problems if you like. (These points become part of your homework grade; each weekly homework assignment is worth around 40 points, so all of the section points for the quarter combine to equal roughly half the weight of one homework assignment.)
You will not be graded on whether you have a perfect solution, but on whether you have demonstrated effort. Therefore please show some work that demonstrates how you got the answer rather than just writing the answer by itself. We will be somewhat lenient about exactly how the work is shown. If you find that you have been working on these problems for more than 30 minutes, please stop and indicate this on your paper. Incomplete solutions can still receive credit.
Section 20: Final review (Thu Dec 5)
Problems: Solve the following three (3) problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 10.20 (10.15 2nd E.) p696 (p675 2nd E.): What is natural ordering? How do you define a natural ordering for a class you've written? (write 2-3 sentences)
- Self-Check 17.20 p1050 (p1028 2nd E.): Draw the binary search tree...
- Self-Chech 17.22 p1050 (p1028 2nd E.): What is the x = change(x)...
Mar 3 2012 12:01 AM
Section 19: Advanced Lists (Tue Dec 3)
Problems: Solve the following two (2) problem on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 9.24 (9.21 2nd E.) p642 (p622 2nd E.): What's wrong with the code for the following interface? (Explain what is wrong in 1-2 sentences, then show the code for a corrected version of the interface.)
- Self-Check 15.23 (15.21 2nd E.) p947 (p925 2nd E.): What changes need to be made to the
indexOf
method...
Nov 24 2013 12:01 AM
Section 18: Polymorphism (Tue Nov 26)
Problems: Solve the following one (1) problem on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 9.17 (9.14 2nd E.) p641 (p622 2nd E.): Suppose that the following variables referring to the classes from the previous problem are declared: ... Which of the following statements produce compiler errors? For the statements that do not produce errors, what is the output of each statement? (Answer for all five lines of code shown. You'll need to look at the Bay / Pond / Ocean / Lake classes declared on the previous page.)
Feb 25 2012 12:01 AM
Section 17: Inheritance (Thu Nov 21)
Problems: Solve the following one (1) problem on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 9.4 (9.3 2nd E.) p635 (p616 2nd E.): Consider the following classes: ... Which of the following are legal statements? (Consider all of (a) - (f).)
Feb 25 2012 12:01 AM
Section 16: Binary Trees 2 (Tue Nov 19)
Problems: Solve the following two (2) problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 17.15 p1049 (p1027 2nd E.): Which of the following trees are valid binary search trees? (consider all of (a) - (e).)
- Self-Check 17.17 p1050 (p1028 2ns E.): Draw the binary search tree that would result if the given elements were added to an empty binary search tree in the given order: Leia, Boba, ...
Feb 18 2012 12:01 AM
Section 15: Binary Trees (Thu Nov 14)
Problems: Solve the following two (2) problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 17.3 p1047 (p1025 2nd E.): How many levels... (solve all of (a) - (e)).
- Self-Check 17.5 p1048 (p1026 2nd E.): Write the elements of the given tree in the order in which they would be seen by a pre-order, in-order, and post-order traversal.
Feb 18 2012 12:01 AM
Section 14: Comparable (Tue Nov 12)
Problems: Solve the following two (2) problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 10.21 (10.16 2nd E.) p696 (p675 2nd E.): Indicate whether the result of each of the following comparisons ... (solve all of (a) - (f). You do not need to show your work.)
- Exercise 10.19 (10.18 2nd E.) p699 (p677): Modify the TimeSpan class from Chapter 8 ... (You can use the following file as a template: TimeSpan.java)
Feb 11 2012 12:01 AM
Section 13: More Recursive Backtracking (Thu Nov 7)
Problems: Solve the following one (1) problem on paper (hand-written or printed) and bring your sheet of paper to either one of the sections this week:
- (not from textbook): Modify the
permute
code from slide 19 of Wednesday's lecture slides so that it outputs the permutations in the opposite order. That is, instead of permute("JANE")
outputting JANE, JAEN, JNAE, ..., it should output ENAJ, ENJA, EANJ, ... Reverse the order by modifying the algorithm and the order in which it chooses various paths to explore, not by literally reversing strings as they are about to be printed. Use the code on slide 19 of Monday's lecture slides as a starting point.
July 16 2012 12:01 AM
Section 12: Recursive Backtracking (Tue Nov 5)
There are no pre-section problems for Section 12. To get section points for this week you will need to do the problems for Section 13. Sorry for the inconvenience.
Section 11: Midterm Review (Thu Oct 31)
Problems: Solve the following two (2) problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 12.7 (12.6 2nd E.) p804 (p766 2nd E.): Convert the following iterative method into a recursive method: ...
- Self-Check 11.9 p733 (p711 2nd E.): Write the
countDuplicates
method described in Self-Check 11.4, and make it so that it can accept either type of list as a parameter as explained in Self-Check 11.9.
Feb 4 2012 12:01 AM
Section 10: Sets and Maps (Tue Oct 29)
Problems: Solve the following two (2) problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 11.10 p733 (p711 2nd E.): A List has every ... (A few sentences will suffice.)
- Self-Check 11.18 (11.20 2nd E.) p734 (p713 2nd E.): What keys and values are contained ... (write the final contents of the map in the following format; the relative order of the keys doesn't matter.
{key1=value1, key2=value2, ...}
July 10 2012 12:01 AM
Section 9: Recursive programming (Thu Oct 24)
Problems: Solve the following two (2) problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 12.17 (12.14 2nd E.) p806 (p767 2nd E.): The following method has a bug ... (Indicate the bug and explain why it causes the method to fail. Why does your change solve the problem?)
- Exercise 12.14 (12.12 2nd E.) p805 (p767 2nd E.): For each of the following calls, indicate the value that is returned: (Solve only parts (a), (c), and (e). Show your work by writing out the series of calls that are made before writing the final output. For example, if mystery1(5) calls mystery1(4), write the sequence of such calls before your answer.
July 9 2012 12:01 AM
Section 8: Recursion (Tue Oct 22)
Problems: Solve the following one (1) problem on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 12.3 p802 (p764 2nd E.):
mystery1
method. For each of the following calls, indicate the output that is produced by the method: (Solve only parts (a), (b), (e) and (f)). Show your work by writing out the series of calls that are made before writing the final output. For example, if mystery1(5) calls mystery1(4), write the sequence of such calls before your answer.
July 2 2012 12:01 AM
Section 7: Linked lists (Thu Oct 17)
Problems: Solve the following two (2) problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 16.19 p998 (p976 2nd E.): An element can be inserted at or removed from the beginning, middle, or ...
- Exercise 16.1 p999 (p977 2nd E.): Write a method called
set
that ... (You can base your solution on the get
method we wrote in lecture on Wednesday. If you're having trouble, do the best that you can in < 30 minutes and turn in your best effort.)
July 2 2012 12:01 AM
Section 6: Linked nodes (Tue Oct 15)
Problems: Solve the following one (1) problem on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 16.6 p997 (p975 2nd E.): Draw a picture of what the given linked nodes would look like after the given code executes.
list.next = new LinkNode(3, list.next);
June 25 2012 12:01 AM
Section 5: Stacks and queues (Thur Oct 10)
Problems: Solve the following three (3) problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- What is the point of using stacks and queues, when an ArrayList can already do all the things they do and more?
- What is the difference between a stack and a queue? Why might we want to use one versus the other? Can you name a situation (real-world or programming) where you want one of these kinds of structures?
- Describe, in English or in pseudo-code, the general idea of an algorithm to reverse the contents of a stack of integers, using only one stack or queue as auxiliary storage. For example, if the stack stores the values [10, 20, 30, 40] from top to bottom, how would you modify it to store [40, 30, 20, 10]?
Jan 7 2012 12:01 AM
Section 4: Testing and debugging (Tue Oct 8)
Problems: Solve the following three (3) problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 15.10 p946 (p924 2nd E.): What is the purpose of ... (A few sentences will be fine. Give at least one specific example.)
- Self-Check 15.13 p946 (p924 2nd E.): Why do we bother to ... (One or two sentences will be fine.)
- Writing tests (not from the textbook): Suppose we have a bug in our
ArrayIntList
where the size is never incremented when add
is called. Write a minimal method that would expose this bug. In other words, your code should include some printlns that would indicate that something bad happened given that bug.
You don't necessarily have to type up and run the code if you don't want to. Just write out the code for this one method manually. It can be very short; write the minimal amount of code you need so that this bug will be visible.
You don't need to write a complete program; just the relevant lines of code to answer the question.
Jan 7 2012 12:01 AM
Section 3: implementing ArrayIntList
and binary search (Thur Oct 3)
Problems: Solve the following two (2) Self-Check problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 13.17 (13.7 2nd E.) p863 (p817 2nd E.): Why does the binary search ... (One sentence is fine.)
- Self-Check 13.18 (13.8 2nd E.) p863 (p817 2nd E.): How many elements (at most) does a ...
You don't need to write a complete program; just the relevant lines of code to answer the question.
Jan 2 2012 12:01 AM
Section 2: implementing ArrayIntList
(Tue Oct 1)
Problems: Solve the following two (2) Self-Check problems on paper (hand-written or printed) and bring your sheet of paper to your section:
- Self-Check 15.7 p946 (p924 2nd E.): An element can be inserted at ...
- Self-Check 15.8 p946 (p924 2nd E.): Write methods called min and max that ... (Write just one of the two methods. Either one is fine. You don't need to write both.)
You don't need to write a complete program; just the relevant lines of code to answer the question.