Professional Documents
Culture Documents
SCHOOL OF COMPUTING
INSTRUCTIONS TO CANDIDATES
1. This assessment paper consists of 2 exercises on 6 pages.
2. This is an open-book assessment. You may bring in any printed material, but not
electronic devices, including but not limited to laptops and thumb-drives.
3. You may bring in a calculator with you.
4. In line with the university rules, any form of communication with other students, or the
use of unauthorised materials is considered cheating and you are liable to the
disciplinary action.
5. Please switch off / silence your mobile phone and keep it out of view.
6. Please leave your student card on the desk in front of you throughout the PE.
7. Your computer has been logged in with a special account. Do not log off or try to log in
with your own NUSNET account.
8. You are to use DrJava installed on the lab computer to write your programs.
9. The skeleton programs have been planted into your working directory: c:\cs1010j.
10. The first 10 minutes of the PE is reserved for you to read questions and design
algorithms. You are not allowed to type your programs in this period of time.
11. You may assume that all input data are valid and no input validation is needed.
12. You are not allowed to use any Java language syntax out of the scope of this PE (e.g.
string or recursion). If in doubt, please check with the invigilator.
13. You are responsible for submitting your programs to CodeCrunch by the end of the PE.
A special password will be issued to you for your submission. Please submit your
programs to CodeCrunch frequently. Do not leave your submission to the last minute
in case of network congestion. You have 99 chances of submissions and only the last
submission will be graded.
14. At the end of the PE, the invigilators will log you out of your computer remotely after
issuing a warning.
15. Grading of the PE will take about 2 weeks.
Sample run #2
Enter date (yyyymmdd): 20171027
Friday
Choice 2: shift the binary image to the left by one position where the left-most column
wraps around to the right.
An example is given below.
a match
In the second example below, there are 3 matches of the pattern image in the binary
image as highlighted.
5 * 5 binary image
Write in the skeleton program BinaryImage.java that has been loaded into your working
directory. In addition to the above three methods, you are also required to complete the
main() method which reads a binary image, a user choice and invokes transpose(),
shift() or match() method according to user choice.
You must NOT change the method headers given in the skeleton program but may write
additional methods as necessary.
A printImage() method is given in the skeleton program. You should use it to print out
transposed/shifted image.
Four sample runs of the program are shown on the next two pages with user's input shown
in bold. For your convenience of testing, test inputs are also appended to the back of your
skeleton program.
Sample run #2
Enter the size of the binary image: 6
Enter the image:
1 1 1 0 0 0
1 0 0 0 0 0
1 1 1 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0
1 0 0 0 0 0
Enter your choice:
(1) transpose
(2) shift
(3) match
2
Image after shift:
1 1 0 0 0 1
0 0 0 0 0 1
1 1 0 0 0 1
0 0 0 0 0 1
0 0 0 0 0 1
0 0 0 0 0 1
Sample run #4
Enter the size of the binary image: 5
Enter the binary image:
0 0 1 0 0
0 1 0 0 0
0 1 0 1 0
1 0 1 0 1
0 0 0 1 0
Enter your choice:
(1) transpose
(2) shift
(3) match
3
Enter the size of the pattern image: 2
Enter the pattern image:
1 0
0 1
Pattern image appears 3 time(s)