Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

ITS D002 Problem Solving

SECTION A

Question 1 (25 marks)

Express the following problem-solving strategies in writing.

(Note: you do not need to write the algorithm/code)

(a)       Describe how Heuristic problem-solving strategy works. Discuss the advantages

and disadvantages of such approach.

(15 marks)

(b)       Provide a real-life (non-computer based) problem example that can be solved by

using Heuristic strategy. Explain in detail the steps and processes involved in such approach.

(10 marks)

Question 2 (25 marks)

Given a list of sorted data: 10, 11, 15, 21, 26, 29 and 44 stored in an array (or list). Perform the following searches.

(Note: you do not need to write the algorithm/code)

(a)       Describe how Binary Search on the data 15” works. State clearly the values of

“first/low”, “mid”, “last/high” indices/positions, and the comparisons made for each step/run.

(12 marks)

(b)       Describe how Binary Search on the data 51” works. State clearly the values of

“first/low”, “mid”, “last/high” indices/positions, and the comparisons made for each step/run.

(13 marks)

SECTION B

Question 3 (25 marks)

Quatre AI Solution is recently engaged by Grip Taxi to develop a program for their drivers to compute the taxi fare of a trip. The driver will need to indicate the number of trips for calculations. For each trip, select whether it is a weekday or weekend & public holiday, enter the passenger boarding time in 24-hour and minute, and the distance travelled in metres. The fare structure for basic fares and surcharges are as follow:


Basic fare:


Flag-down (inclusive of 1st km or less)

$3.90

Every 400m thereafter

$0.22


Surcharge:


Day Type

Midnight            (12am – 5:59am)

Peak-hour         (6am – 9:29am)

Peak-hour         (6pm- 11:59pm)

Weekdays

+ 50%

+ 25%

+ 25%

Weekends / PH

+ 50%

None

+ 25%

Design a program to read the number of trips, the day type, the boarding time, and the distance travelled. The program will need to compute and display the total taxi fare for each trip.


Calculation examples (Note: these need not be your input/output design):


1.   Day Type: 2 [i.e., Weekend / PH]

Boarding hour and minute: 14 27 [i.e., 2:27pm, 867mins] Distance travelled: 10950 [i.e., 10km 950m]

Flag-down: $3.90

Next 9950m: 24.875 x $0.22 = $5.4725 [i.e., 9950 / 400] Basic fare: $9.3725

Surcharge: $0

Total fare: $9.3725 [i.e., ignore rounding]

2.   Day Type: 1 [i.e., Weekday]

Boarding hour and minute: 9 20 [i.e., 9:20am, 560mins] Distance travelled: 6123 [i.e., 6km 123m]

Flag-down: $3.90

Next 5123m: 12.8075 x $0.22 = $2.81765 [i.e., 5123 / 400] Basic fare: $6.71765

Surcharge: 25% x $6.71765 = $1.6794125

Total fare: $8.3970625 [i e , ignore rounding]

3.   Day Type: 1 [i.e., Weekday]

Boarding hour and minute: 5 59 [i.e., 5:59am, 359mins] Distance travelled: 9000 [i.e., 9km]

Flag-down: $3.90

Next 8000m: 20 x $0.22 = $4.40 [i.e., 8000 / 400]

Basic fare: $8.30

Surcharge: 50% x $8.30 = $4.15

Total fare: $12.45 [i.e., ignore rounding]

(a)       Write an algorithm for the program.

(12 marks)

(b)       Draw a flowchart for the program.

(13 marks)

Question 4 (25 marks)

Based on the problem scenario described in Question 3.

(a)        Write a pseudocode for the program.

(12 marks)

(b)       Code the program in Python. Do indicate the Python version used and useful

comments in your codes.

(Note: Type your codes to the answer sheet, you do not need to submit the *.py file)

(13 marks)