讲解CN5102、讲解Java、Java编程调试、辅导Data Structures
- 首页 >> Java编程SCHOOL OF ARCHITECTURE, COMPUTING &
ENGINEERING
Submission instructions
Cover sheet to be attached to the front of the assignment when submitted
Question paper to be attached to assignment when submitted
All pages to be numbered sequentially
All work has to be presented in a ready to submit state upon arrival at the
ACE Helpdesk. Assignment cover sheets or stationery will NOT be
provided by Helpdesk staff
Module code CN5102 HDU
Module title Data Structures and Algorithms
Module leader Amin Karami
Assignment tutor Amin Karami
Assignment title Coursework
Assignment number 1
Weighting 50%
Handout date 10/12/2018
Submission date 30/01/2019
Learning outcomes
assessed by this
assignment
5, 6, 7, 8, and 9
Turnitin submission
requirement
YES Turnitin GradeMark feedback
used?
NO
UEL Plus Grade Book
submission used?
NO UEL Plus Grade Book
feedback used?
NO
Other electronic
system used?
no Are submissions / feedback
totally electronic?
yes
Additional information
ASSESSMENT FEEDBACK - Feedback on your assessment
will be available in four working weeks from the submission
date. Please refer to the module pages on Moodle for
assessment specific details.
2
Form of assessment:
Individual work Group work
For group work assessment which requires members to submit both individual and
group work aspects for the assignment, the work should be submitted as:
Consolidated single document Separately by each member
Number of assignment copies required:
1 2 Other
Assignment to be presented in the following format:
On-line submission
Stapled once in the top left-hand corner
Glue bound
Spiral bound
Placed in a A4 ring bound folder (not lever arch)
Note: To students submitting work on A3/A2 boards, work has to be contained
in suitable protective case to ensure any damage to work is avoided.
Soft copy:
CD (to be attached to the work in an envelope or purpose made wallet
adhered to the rear)
USB (to be attached to the work in an envelope or purpose made wallet
adhered to the rear)
Soft copy not required
Note to all students
Assignment cover sheets can be downloaded from logging into UEL Direct via the
following pathway.
UEL Direct → My Record → My Programme → Assessment log dates with Barcoded Front sheet
All work has to be presented in a ready to submit state upon arrival at the ACE Helpdesk.
Assignment cover sheets or stationery (including staplers) will NOT be provided by
Helpdesk staff. This will mean students will not be able to staple cover sheets at the
Helpdesk.
3
Marking Scheme
Topic Total
mark
Remarks
(breakdown of marks for each sub-task)
Linear Data
Structure 50
Develop a Java-based integer calculator through stack, array, and linkedlist
data structures.
Non-Linear
Data Structure
50
(30) Develop a BSTree with Java programming
(6) Binary Tree (BT) Traversal
(4) Considering a Max-Heap Tree in the form of array representation
and inserting a new key
(10) Converting Post-order Traversing to Pre-order Traversing in BST
Good Luck!
4
CN5102 Data Structures and Algorithms - HDU
Assignment 2018-19 Academic Year
1. Design an Integer Calculator by Stack (50 marks)
Your first task is to implement a basic calculator that supports integer operands like 1,
5432, and -35 as well as the (binary) integer operators +, -, *, /, and %. Your task
is to write a Java program that uses stack data structure. The user enters input through
System.in consisting of operands and operators, presumably in postfix (or prefix) notation.
We have also included some extra operators to get information about results and the current
state of the stack:
If the user enters a valid integer, you push that integer onto the stack.
If the user enters a valid operator, you pop two integers off the stack, perform the
requested operation, and push the result back onto the stack.
If the user enters the symbol ? (a question mark), you print the current state of the
stack.
If the user enters the symbol ^ (a caret), you pop the top element off the stack and
print only that element (not the entire stack).
If the user enters the symbol ! (an exclamation mark), you exit the program.
If the user enters string variable (e.g., hi) or 1.5 or anything else that doesn’t
make sense for an integer calculator, your program should stop calculation and print
an error message.
If the user requests an operation for which there are not enough operands on the
stack, your program should notify the user of the problem but leave the stack
unchanged.
Example 1:
(user input):
10 20 30 * + ^ !
(calculator respond):
[]
[10]
[30, 20, 10]
[600, 10]
[610]
610
[]
5
Example 2:
(user input):
1 2 blah 1.0 3
(calculator respond):
#Invalid input.
#Invalid input.
[3, 2, 1]
(user input):
+ +
(calculator respond):
[6]
(user input):
+ +
(calculator respond):
#Not enough arguments.
#Not enough arguments.
[6]
(user input):
!
1- Test your Java program with the above input/output examples.
2- Copy-paste your Java codes into report, clearly with the required comments to
understand your codes.
3- You need to use either array or linked list for stack implementation.
6
2. Non-linear Data Structure (50 marks)
Question 2.1 [Total 30]:
Write a Java program to implement a BSTree as follows:
Get integer or string values from users
Put them into a BSTree
Print the BSTree. This representation should:
o print each node in a separate line
o print null nodes
o print the left subtree before the right subtree
Example:
(1) User input:
S, E, R, X, A, C, H, M
(2) As BSTree format, it looks like:
(3) Your java program must return something like:
-S
|-E
| |-A
| | |-null
| | -C
| | |-null
| | -null
| -R
| |-H
| | |-null
| | -M
| | |-null
| | -null
| -null
-X
|-null
-null
7
Question 2.2 What is the outcome of inorder traversal on this Binary Tree (BT) How
about postorder traversal and preorder traversal? (6 Points)
Question 2.3 Consider the following binary tree representation of a max-heap. (4 Points)
(a) Give the array representation of the heap.
0 1 2 3 4 5 6 7 8 9 10 11 12
- -
(b) Insert the key Q into the binary heap above, circling any entries that changed.
0 1 2 3 4 5 6 7 8 9 10 11 12
-
Question 2.4 What is the 2nd key and 7th key in the pre-order traversal of the below postorder
traversal of a BST? Draw your solution. (10 Points)
Post-order: 5, 6, 15, 10, 23, 24, 22, 26, 20
8
Submission
Each student is required to submit two things:
For programing questions:
o One Eclipse project with all the source codes in a zip file named with the
student id number. Please name the Java programs as requested in each
exercise.
Report: please use the assignment template as a single doc file to all the exercises
accordingly. You can download the template from Moodle. Note: copy and paste
all the source codes into the doc file for those questions asking Java programming.
Turnitin submission: you have to upload two files separately into Turnitin submission
link. To do so, upload your Java codes into Java codes tab, and upload your report into
Report tab.
It is the student responsibility to produce a clear and easily understood document. To do
this:
Check the spelling and grammar in your document.
Use clear, short, and precise language.
Number the pages.
Create a table of contents for your document.
For every figure in your document use a number and a title.
Write references/citations in a standard format.
Explain terms, acronyms, and abbreviations.
Review the document and check for inconsistencies, omissions, redundancies.
Plagiarism
The University defines an assessment offence as any action(s) or behaviour likely to confer an unfair
advantage in assessment, whether by advantaging the alleged offender or disadvantaging
(deliberately or unconsciously) another or others. A number of examples are set out in the
Regulations and these include:
“D.5.7.1 (e) the submission of material (written, visual or oral), originally produced by another
person or persons, without due acknowledgement, so that the work could be assumed the student’s
own. For the purposes of these Regulations, this includes incorporation of significant extracts or
elements taken from the work of (an) other(s), without acknowledgement or reference, and the
submission of work produced in collaboration for an assignment based on the assessment of
individual work. (Such offences are typically described as plagiarism and collusion.)”
The University's Assessment Offences Regulations can be found on our web site. Also, information
about plagiarism can be found on the programme’s handbook.