Name:_____________________________________________
Part 1 of 6 (Thursday, 14 March 2019)
Part 1a - Easy Coding Problem
- On a blank sheet of paper, compose a Java program that prints five random integers, one per line, between 1 (inclusive) and 300 (inclusive).
- Enter your program code into a Java development environment (e.g. Jdoodle) and run it once. (Debug your program if necessary.) What five integers did your program print?
- __________
- __________
- __________
- __________
- __________
- __________
Part 1b - Extra Credit (worth up to 4% to be added to your total score for this exam)
Dr. Evan Cohn will be speaking at Career Day today. This is his bio:
Evan Cohn
BS in Applied Mathematics, Harvard 1982
MS Computer Science Stanford 1985
PhD Computer Science, Stanford 1988
Shell Research (Houston Texas) 1988-1993 Intel Corporation (Santa Clara and Portland) 1993-2011 currently retiredEvan has also worked at Bell Labs, IBM, and been in a start-up. His daughter is currently a computer science major (Stanford sophomore). His wife is a professor of computer science at the University of Washington. His PhD advisor remembers him fondly, but not as fondly as another of his advisees, Sergei Brin (founder of Google).
Evan is an excellent tennis player and gave fascinating lectures at VCHS two years ago during Investment Club meetings. Evan's wife is Professor Anna Karlin. Anna's father is the late renowned mathematics professor, Samuel (Sam) Karlin. Anna's brother, Dr. Manuel (Manny) Karlin, is a physician and is our very own Marty Karlin's husband. Evan's (and Anna's) Ph.D. advisor at Stanford was Jeffrey D. Ullman, co-author of the textbook that Mr. Spurgeon used in his first algorithms and data structures course at Purdue University. Jeffrey D. Ullman and Samuel Karlin were colleagues of Don Knuth when Knuth was teaching at Stanford before he retired to work full-time on The Art of Computer Programming. Anna was once a teaching assistant for a Stanford course called “Concrete Mathematics”—which is also the name of a famous textbook that was created for the course. Concrete Mathematics focuses and expands on topics Knuth presents in section 1.2 of The Art of Computer Programming.
- Go to https://www.amazon.com/Advice-Daughter-Evan-Cohn-ebook/dp/B00DAHYJD4/. Purchase a copy of Evan's book for $0.99 or ask Mr. Spurgeon to purchase a copy for you. Read precept number 1 and the five precepts corresponding to the randomly generated numbers your program produced in the previous exercise.
- Read the following Wikipedia articles:
- Think of a good a question (e.g. something related to the precepts you read, one of the Wikipedia articles your read, Knuth, Stanford, computer science, tennis, investing, college, family, life, etc.) that you would like to ask Dr. Cohn, and ask him your question during career day.
- Email Mr. Spurgeon a copy of the question you asked and a description/summary of Dr. Cohn's response.
- Thank Dr. Cohn in person, and write him a thank-you note; send him your note, and send a copy to Mr. Spurgeon. (Or send your note to Mr. Spurgeon to forward to Dr. Cohn.)
- Which of the five precepts that you read was most interesting to you? Why? Email your answers to Mr. Spurgeon.
Name:_____________________________________________
Part 2 of 6 (Friday, 15 March 2019)
10 multiple choice questions provided in class.
Parts 3-6 of 6 (Friday-Thursday, 15-21 March 2019)
Parts 3-5 refer to the program code posted at https://apcsafreeresponsequestions.blogspot.com/2019/03/permutations.htmlEmail your answers to Parts 3-6 to Mr. Spurgeon's vcstudent email account by the end of the school day, Thursday, 21 March 2019. You may discuss how you are approaching the problems with others, but do ALL of the actual coding yourself and do NOT share any of your source code with other students in the class; Cite any and all forms of collaboration. If you are caught turning in code that someone else wrote, then BOTH you AND the person who wrote the original code will receive a ZERO for the coding portion of the exam and your actions will be reported to the dean of students. (Do NOT share your code with others!)
Part 3
Provide a proper implementation of the methodareEqual
.
Part 4
Provide proper implementations oftoGrid
, toUpsideDown
, and toMirrorImage
.
Part 5
This part of the exam is optional; however, if you decide not to do it, then the highest mark you will be able to receive for the coding portion of the exam will be a "check" (89%).
Change the method toListOfPermutations: Make the method recursive without changing the essential functionality of the method; the recursive method must still generate all possible permutations of a series of values, but it does not necessarily have to list them in the same order as the original non-recursive method.
Part 6
This part of the exam is optional; however, if you decide not to do it, then the highest mark you will be able to receive for the coding portion of the exam will be a "check plus" (95%).
Develop a program that takes five inputs and produces the output described below.
The Inputs
- A positive integer, n, representing the number of sheets in a roll of toilet paper.
- A positive integer, m, representing the number of sheets in another roll of toilet paper.
- A positive probability (a positive floating pointer), p, that is less than one and represents the probability that a consumer will take a single sheet of paper from a roll that currently contains the maximum number of sheets at the point in time when the sheet is consumed.
- A positive integer, t, representing the numbers of times the simulation described below will be performed.
The Simulation
Using the values of n, m, and p provided as inputs, your program should simulate a single consumer consuming toilet paper, one sheet at a time, until one of the rolls of toilet paper is empty. Your program should perform the same simulation t times.The Output
Your program should output four labeled values: the average number, the maximum number, the minimum number, and the standard deviation of the number of sheets of toilet paper remaining on one of the two rolls of toilet paper when the other roll becomes empty.Credit
The inspiration for this problem is a story involving Don Knuth that Evan Cohn told during Career Day. A paper describing the original problem is posted at: https://www.jstor.org/stable/2322567?seq=1#page_scan_tab_contents.