DSAG Project 1 A
DSAG Project 1 A
DSAG Project 1 A
PROJECT 1 (80%)
This is an individual assignment. Your submission must not contain any plagiarized materials
and source code.
Objectives
This assignment requires students to put into practice the various topics covered so far in data
structures and algorithms.
PART A (50%)
Recall how the Insertion Sort works. It starts from the left of the list and sorts up to
where the counter is. Modify the Insertion Sort such that it starts from the right of the
list and sorts until where the counter is.
def insertionSort(list):
for index in range(1, len(list)):
currentvalue = list[index]
position = index
list[position] = currentvalue
Note : A, B, C, D and E refer to one of the last five digits of your student’s admin
number. For example, the last five numerical digits are 32605, so A = 3, B = 2, C = 6, D
= 0 and E = 5.
a. Show with the aid of a series of diagrams to search for the number 177 using Binary
Search algorithm. Do note that calculation of middle for each iteration at each step
should be shown.
There is a mystery gift vending machine in Wonder Mall which dispenses a random
gift upon receipt of payment in cash.
Write a prototype program (in Python) that will simulate the mystery gift vending
machine using stack data structure. No other data structures is allowed for this
question.
The program will have a stack data structure with 8 gifts pushed to it as below.
No. Gifts
1 iPhone XS
2 Wireless Headphones
3 Stuffed Bunny Toy
4 Nike Cap
5 Silver Heart Pendant
6 Happy Birthday Photo Frame
7 Gadget Key Chain
8 Smart Watch
The vending machine will display the list of gifts so as to attract buyers.
Upon receiving payment, it will generate and display 3 different random gifts. This is
to create suspense and excitement.
After which, it will dispense the mystery gift which is 1 of the 3 gifts displayed earlier.
At the end of the game, it will display the remaining gifts in the machine in the same
order as before.
Use logic compound statement learnt in LOMA to construct the condition for
generating 3 different random numbers. Use sequence and recursion learnt in LOMA
to construct an appropriate loop that allows the machine to dispense the mystery gift
and displays the remaining gifts in the machine.
Sample Output:
~ Mystery Gift Vending Machine ~
1 - iPhone XS
2 - Wireless Headphones
3 - Stuffed Bunny Toy
4 - Nike Cap
5 - Silver Heart Pendant
6 - Happy Birthday Photo Frame
7 - Gadget Key Chain
8 - Smart Watch
This question requires logic, and sequence and recursion learnt in LOMA and statistics
in DANA.
Sample Output:
Preliminary round starts ...
Modify the following Bubble Sort code such that it uses recursion and achieves the
same output as its other counterpart.
Run the list at the end of the code to ensure that your program works.
This question requires logic, and sequence and recursion learnt in LOMA.
def bubbleSort(list):
for i in range(len(list)-1,0,-1):
for j in range(i):
if list[j] > list[j+1]:
temp = list[j]
list[j] = list[j+1]
list[j+1] = temp
Do note that your function should only take in a list and the size of the list as
parameters.
The status report must be typed-written using Microsoft Word with 1 inch margin all round,
portrait, Times New Roman font, size 12, single line spacing. Proper English MUST be used for
the writing of report.
Write a short summary of the final state of your assignment in a file called
Status_<YourName>_<AdminNumber>.doc.
E.g. Status_LimChuKang_1809115J.doc.
Total: 50%
Part A %
1. Inverse Insertion Sort 4
2. Search Algorithms 8
3. Mystery Gift Vending Machine 10
4. National Data Analytics Challenge 8
5. Conversion Using Recursion 6
Programming Style (Documentation/Comments) 3
Additional features/ Efficient code 6
(One additional feature be awarded 1 mark)
Report 5
Total 50
Deliverables
There are a total of THREE items which you need to submit as follows:
a) Status Report with its cover page as shown in Appendix 1, which can be found at the
end of this assignment specification.
b) All answers are accompanied by detailed computations and workings (e.g. tables,
diagrams, etc.). Include answers for Q2.
2) Program/Coding files
Method of Submission
The report and the program/coding files must be compressed into a .zip file and labeled as
[your_matric_no].zip. (E.g. 1801234A.zip). Please do not use other file compression methods
(e.g. rar).
This zip file must be submitted electronically to TP-LMS before the deadline.
Penalty
syntax, link and runtime errors (so test early and test often!)
lack of comments and missing header comments
poor programming styles (including indentation, variable naming etc.)
poorly written/formatted status report
late submission
plagiarised or copied work.
late and <1 day : 10% deduction from absolute mark given for the component
late>=1 and <2 days : 20% deduction from absolute mark for the component
late>=2 days : No marks awarded
Note that “day” includes non-working days (Sat, Sun and public holidays).
General MC/LOA is NOT considered as valid reason for extended assignment submission.
Temasek Polytechnic
School of Informatics & IT
Assumptions
This section should include your assumptions made for your solutions and reason why you
need such assumptions.
Additional features
References
“By submitting this work, I am / we are declaring that I am / we are the originator(s) of
this work and that all other original sources used in this work has been appropriately
acknowledged.
I / We understand that plagiarism is the act of taking and using the whole or any part of
another person’s work and presenting it as my/ our own without proper
acknowledgement.
I / We also understand that plagiarism is an academic offence and that disciplinary action
will be taken for plagiarism.”