Decorative banner

Topic 4 - Computational thinking, problem-solving and programming

Question 1

HLPaper 1

A number of devices in and around the home can be operated by control systems.

A home owner wishes to install automatic lights to illuminate a water fountain in her garden. These lights will automatically turn on at sunset and turn off at sunrise.

1.

Describe two hardware components that would be an essential part of this control system.

[4]
2.

Explain the concept of feedback, with respect to computer control systems in general.

[3]
3.

The home owner has also installed a control system that waters the flowerbeds in the garden. This system aims to maintain the water content of the flowerbeds between a minimum and a maximum value. However, the system is only activated when the light intensity is below a certain level.

Outline the algorithm involved in controlling the watering system described above.

[5]

Question 2

SLPaper 1

A company has 600 employees whose names are currently stored using a collection called NAMES. The names are stored as surname, first name. For example: Smith, Jane, Uysal, Rafael, Ahmed, Ishmael, Jonsonn, Sara, …

The names in the collection are kept in a random order. However, it would be more useful if they were kept in alphabetical order.

The company’s staff list is now organized in the arrays in alphabetical order.

A binary search was used to find a specific name in the array.

1.

Construct a pseudocode algorithm that will store the surnames in one array and first names in another.

[4]
2.

Construct a pseudocode algorithm that will sort the surnames into alphabetical order using the bubble sort method. The order of the first names must also be changed so that they keep the same index as their corresponding surname.

[5]
3.

Describe the process a binary search would follow to find a record in the surname array.

[4]
4.

Outline one benefit of using sub-programmes to implement your algorithms from parts (a) and (b).

[2]

Question 3

SLPaper 1

For an identified application, explain why a binary search would be preferred to a linear search.

Question 4

SLPaper 1

Describe the steps involved in using the bubble sort algorithm to sort an array.

Question 5

SLPaper 1

A school has 100 students. All student names (strings) and student ID numbers (five-digit integers) are held in two separate one-dimensional arrays named SIDand SNAMES.

For example, student Pia Baranger has ID number 11876.

A binary search algorithm is not used to find a particular name in arraySNAMES.

The school offers its sporting program to students and has a basketball team, a tennis team and a football team. Each student must choose at least one of these three sports.

Three collections,BASKETBALL, TENNIS and FOOTBALL, are created. When a student chooses a sporting activity, their ID number is added to the appropriate collection.

For example:

BASKETBALL={10011, 11876, 10122}
TENNIS={10011, 11876, 10002}
FOOTBALL={10011, 10002, 22103, 32000}

The method isIn(X, COL)is available, where:

  • Xis a five-digit integer representing an ID number
  • COLis a collection that holds student ID numbers.

The method isIn(X, COL)returns Trueif the ID number Xis in the collection COL; Falseotherwise.

For example:

isIn(11876, BASKETBALL) returns True
isIn(11876, FOOTBALL) returns False

The football and tennis training sessions are held at the same time. The football coach would like to know how many students will not be able to attend the football training session because they will be attending the tennis training session.

1.

State the reason for not using a binary search.

[1]
2.

Construct an algorithm in pseudocode for the method isIn(X, COL).

[4]
3.

Construct an algorithm in pseudocode that will output the number of students who have chosen both tennis and football. The method isIn()should be used in your answer.

[3]
4.

The school coordinator would like to check whether there are students who have not yet chosen any one of the three sports.

Construct an algorithm in pseudocode that will output the names of students who have not yet chosen any one of the three sports. An appropriate message should be displayed if every student has chosen a sport.

[7]

Question 6

SLPaper 2

An airport uses an object-oriented program to keep track of arrivals and departures of planes. There are many objects in this system and some are listed below.

The code below outlines the Arrivalclass used in this program.

public class Flight
{ private String id;
public String getId() {return this.id;}
// ... more variables, accessor and mutator methods
}
**
public class** Arrival
{ private Flight myFlight;
private String sta; // Scheduled Time of Arrival ('hh:mm')
private int runway;
private String gate;
private int delay;
private boolean landed;

public Arrival(Flight myFlight, String sta)
{ **this.**myFlight = myFlight;
**this.**sta = sta;
**this.**runway = 0;
**this.**gate = null;
**this.**delay = 0;
**this.**landed = false;
}

public void addDelay(int newDelay)
{ **this.**delay = newDelay;
}

public String getETA()
{ // calculates the Estimated Time of Arrival (ETA) of the flight
// by adding the delay to the sta and returning the result as a
// String ('hh:mm')
}

public int compareWith(String flightID)
{ if (myFlight.getID().equals(flightID)) { return 0; }
else { return 1; }
}

public int compareWith(Arrival anotherArrival)
{ // missing code
}

// ... plus accessor and mutator methods
}

The code below outlines part of the FlightManagementclass used in this program.

For the purposes of this exam only arriving flights are being considered.

public class FlightManagement
{
private Arrival[] inbound; // array of inbound airplanes
private int last = -1; // index of last used entry
public FlightManagement()
{ inbound = new Arrival[200];
}
public void add(Arrival newArrival)
{ // missing code that adds the newArrival to the array inbound
// sorted by ETA, and updates last
}

private int search (String flightID)
{ // missing code that searches the array inbound and
// returns the index of the Arrival object with flightID
}

public Arrival remove(String flightID)
{ Arrival result;
int index = search(flightID);
result = inbound[index];
while (index < last)
{ inbound[index] = inbound[index + 1];
index++;
}
last--;
return result;
}

// ... many more methods
}

The method searchin the FlightManagementclass searches the array inboundand returns the index of the Arrivalobject with the given flightID.

1.

Outline the general nature of an object.

[2]
2.

Describe two disadvantages of using Object Oriented Programming (OOP).

[4]
3.

Outline one advantage of using modularity in program development.

[2]
4.

State the relationship between the Flightobject and the Arrivalobject.

[1]
5.

Construct a UML diagram to represent theArrivalobject.

[4]
6.

Construct the method searchimplementing a linear search. Use the first compareWith()method in the Arrivalobject.

You may assume that an Arrivalobject with the given flightIDexists in the array inbound.

[4]
7.

Outline one advantage of using a binary search.

[2]
8.

Outline one disadvantage of using a binary search.

[2]

Question 7

HLPaper 1

An oil and gas company has a networked computer system for use of their employees in the Head Office.

The company also uses the internet to enable communication with employees working on exploration and production in many remote geographical areas.

The sub-sea oil and gas exploration and production unit of the company relies on thousands of kilometres of pipeline which are monitored by a computer control system which can detect leaks.

The process of detecting leaks is carried out by sensors which are continuously monitoring changes in the flow and pressure of the liquids in the pipes.

This data is processed on a computer in the office.

If any of sensor values are outside of the acceptable parameters stored on a disk in the office, the following error routines are performed:

  • an alarm is sounded on the computer at the office
  • an email message is sent to managers in the Head Office.
1.

Identify one hardware security measure that will ensure that confidential data from the Head Office cannot be accessed.

[1]
2.

Identify one software security measure that will ensure that confidential data from the Head Office cannot be accessed.

[1]
3.

Identify one network security measure.

[1]
4.

Explain the environmental benefit of using a computer control system to monitor the pipeline.

[3]
5.

Explain the relationship between sensors, output transducers and processor in this situation.

[4]
6.

Construct a system flowchart to represent the process described above.

[5]

Question 8

SLPaper 1

A medical centre uses a computer system to manage both patients’ data and appointments. This system, which is used by the doctors, nurses and secretaries, has two unordered files: a patients’ file and an appointments’ file, both of which can only be accessed sequentially.

Every evening the following processing takes place:

  • a list of appointments for the next day is printed out
  • reminders are sent by SMS text messages to the patients’ mobile devices.
1.

Outline the pseudocode that the processing must follow when the system sends out the text reminders.

[5]
2.

Describe two different methods that the medical centre could use that would allow data to be restored should it be lost for any reason.

[4]
3.

The medical centre is concerned about the privacy of the data it is storing and has to make decisions concerning:

  • access to the data stored on this system
  • storing the data locally or through the use of a cloud service.

Discuss the issues that should be considered before making these decisions.

[6]

Question 9

SLPaper 1

Outline the need for a translation process from high level language to machine code.

Question 10

SLPaper 1
1.

Identify one fundamental operation of a computer.

[1]
2.

Distinguish between fundamental and compound operations of a computer.

[2]
Jojo

Intern at RevisionDojo this summer!

Gain work experience and make an impact on thousands of students worldwide. Limited spots available.