Assignment_2
Assignment_2
Instructions:
5. Please read the instructions given in the questions carefully. In case of any
ambiguity, post your queries on Google Classroom at least 3 days before the
deadline. No TA will be responsible for responding to the queries
after this.
6. All the TAs will strictly follow the rubric provided to them. No requests
will be entertained related to the scoring strategy.
432, 235, 129, 543, 602, 764, 230, 987, 564, 345
1.1. Using Radix Sort, show how these numbers would be sorted step by step and show
your working. (15 marks)
1.2. After sorting, explain why Radix Sort is more efficient than Comparison-based Sort-
ing algorithms for sorting large numbers of integers. Also, does Radix sort work for smaller
integers? Why or why not? (5 marks)
1. Larger shipments (those with more items) should ideally be processed first.
2. If two shipments have the same size, perishable items should be processed first.
3. If both shipments have the same size and perishability, the decision is made alphabet-
ically (A before B, B before C, etc.).
2.1. Draw a decision tree for the five shipments based on the manager’s decision rules.
Demonstrate how your decision tree would give an optimal arrival order for the shipments
using a descriptive example (assume some size and perishability properties for each ship-
ment). (15 marks)
2.2. At the end of each month, the warehouse receives double the load of shipments,
adding up to a total of 10. If every order of the shipments arrival is valid, estimate how many
leaves the decision tree must have to represent all possible processing orders using Stirling’s
approximation. Also compute the minimum height h of this end-of-month decision tree.
Show your working. (5 marks).
Hint: Estimate the number of permutations of 10 shipments as 10! using
Stirling’s approximation. The minimum height of a decision tree with N pos-
sible orderings is approximately lg(N !).
3 Stack/Queues (20 Marks)
3.1 Parcel Tracking System
You are working on a parcel tracking system for a logistics company. The company handles
priority-based parcel delivery, where urgent parcels are processed first. You must implement
a stack using a linked list to simulate the parcel-handling process (12 Marks).
Each parcel contains the following information: Tracking ID (a unique integer), Sender Name
(string, max 50 characters), Receiver Name (string, max 50 characters), Weight (kg) (float),
Priority Level (1 = High, 2 = Medium, 3 = Low).
This tracking system now requires a search feature that allows staff to quickly find the
parcel by their ID (8 Marks); Search parcel by Tracking ID → Search for a parcel by their
ID and display their details.
– (12, 45)
– (34, 89)
– (23, 78)
– (12, 56)
– (45, 89)
• Search for the coordinate (23, 78) and display whether it is found or not.