Augment’s own questions for Computer Science, written in the style of IB exams, each with its markscheme. They are not past papers. One from each topic is below to try.
Every question has a markscheme.
The paper each question is written for, so you can practice one paper at a time.
Each topic in syllabus order, with its subtopics. Lines with notes link to them. Under each topic is one question to try, its markscheme folded until you open it.
A coastal weather station measures wind speed and humidity. Each reading is stored as an 8-bit unsigned binary integer before it is sent to a central server.
The latest wind speed reading is 1011 0110. State this value in decimal.
1 mark
The latest humidity reading is 203 in decimal. State this value in hexadecimal.
1 mark
State the largest value that one reading can hold.
1 mark
Outline one reason why the station's engineers display readings in hexadecimal rather than binary when testing the equipment.
2 marks
182;
CB;
Note: Accept , 0xCB or lower case cb.
255;
Note: Do not accept 256.
Award [1] for the reason and [1] for the development, up to [2 max].
Hexadecimal is shorter / more compact (two digits instead of eight);
so it is quicker to read and copy, with fewer transcription errors;
Each hex digit maps to exactly four bits;
so it converts to and from binary easily (unlike decimal);
Note: Do not accept "hexadecimal uses less memory": the stored data is still binary.
A dental clinic has the network shown in Figure 1. Every device is connected by its own cable to one switch.
Identify the topology used inside the clinic.
1 mark
Outline the effect on the clinic if the cable to Surgery 2 PC is cut.
2 marks
Outline the effect on the clinic if the switch fails.
2 marks
Explain how using a switch at the centre of the star helps to avoid data collisions on the clinic's network.
3 marks
The clinic manager suggests replacing the star with a full mesh, in which every device is cabled directly to every other device.
Discuss whether this would be a sensible change for the clinic.
4 marks
Star (topology);
Award [1] for the effect on Surgery 2 PC and [1] for the effect on the rest of the network.
Surgery 2 PC can no longer reach the file server / printer / internet;
the other devices carry on working normally / are unaffected (because each has its own link to the switch);
Award [1] for the effect and [1] for the reason.
No device can communicate with any other device / no PC can reach the file server, printer or internet;
because all traffic passes through the switch / the switch is a single point of failure;
Award [1] per point, up to [3 max].
Each device has its own dedicated link/port to the switch;
the switch reads the destination (MAC) address of each frame;
and forwards it only to the port of the destination device / does not send it to every device;
so two devices can transmit at the same time without their signals interfering;
(full-duplex links mean) a device can send and receive at the same time;
any frames arriving together for the same port are buffered/queued by the switch rather than colliding;
Award [1] for each relevant point, up to [3 max] for points on one side only, and [1] for a conclusion that follows from the points made, up to [4 max].
For a mesh: no single point of failure / losing one link or device does not cut off the others;
traffic has alternative paths so reliability is higher;
Against a mesh: the number of cables grows rapidly / the 7 devices (including the router) would need 21 links instead of 7;
each device would need many network ports/NICs, raising the cost;
installation and fault-finding are far more complex;
the clinic is small, so the extra reliability is not worth the cost / a spare switch would be cheaper;
the router/internet link would still be a single point of failure;
Conclusion: e.g. a mesh is not sensible; a spare switch or a second switch with redundant links gives most of the benefit at far lower cost;
Note: Accept a conclusion in favour of the mesh if it is justified by the clinic's need for reliability.
A veterinary clinic stores details of pets and their owners in a relational database. Sample data from two of its tables is shown.
Owner
OwnerID | OwnerName | Phone |
|---|---|---|
OW101 | Amira Haddad | 0412 556 019 |
OW102 | Tomas Lindqvist | 0420 773 145 |
OW103 | Grace Okafor | 0433 908 262 |
Pet
PetID | PetName | Species | OwnerID |
|---|---|---|---|
P5001 | Biscuit | Dog | OW102 |
P5002 | Luna | Cat | OW101 |
P5003 | Pepper | Rabbit | OW102 |
P5004 | Max | Dog | OW103 |
Identify the primary key of the Owner table.
1 mark
Identify the foreign key in the Pet table.
1 mark
Explain why the value OW102 may appear more than once in the Pet table but only once in the Owner table.
2 marks
OwnerID;
Note: Do not accept OwnerName or Phone.
OwnerID (in Pet);
Award [1] for the Owner side and [1] for the Pet side.
In Owner, OwnerID is the primary key so each value must be unique / identifies exactly one owner;
In Pet, OwnerID is a foreign key, which does not need to be unique;
because one owner can have many pets / one-to-many relationship (Tomas owns Biscuit and Pepper);
Note: Award [2 max].
A hospital has 40 000 chest X-ray images. A radiologist has tagged each image as either pneumonia or healthy. The hospital wants a machine learning model that flags new X-rays that may show pneumonia.
Identify the type of machine learning the hospital should use.
1 mark
Outline why the radiologist's tags are needed to train this model.
2 marks
Describe how the trained model would be used when a new patient's X-ray is taken.
3 marks
Supervised learning;
Note: Accept "supervised learning using deep learning". Do not accept "deep learning" alone.
Award [1] for the point and [1] for the development.
The tags are the labels / correct answers for each training image;
the model learns the link between image features and the label / compares its prediction with the tag and adjusts;
without labels the model would have no way of knowing which images show pneumonia;
so it could not learn to predict the category for new images;
Award [1] per point, up to [3 max].
The new image is input to the trained model;
the model applies the patterns it learned in training (it is not retrained);
it outputs a predicted class / pneumonia or healthy;
(often) with a confidence score / probability;
images flagged as possible pneumonia are passed to / prioritised for a radiologist to check;
the final diagnosis is made by a clinician;
A college print room sends every print job to a single printer. Jobs wait in a queue and the printer always takes the job at the front. The queue starts empty, and then these operations happen in order:
enqueue(J1), enqueue(J2), enqueue(J3), dequeue(), enqueue(J4), dequeue(), enqueue(J5)
State the job that the printer will print next.
1 mark
State the contents of the queue after the operations, from front to rear.
2 marks
Outline one reason why a queue is a suitable structure for the print jobs.
2 marks
J3;
Award [1] for J3 at the front and [1] for J4, J5 following in that order.
J3 at the front;
then J4, then J5 at the rear;
Note: Accept a labelled diagram of the queue.
Award [1] for the reason and [1] for the expansion.
a queue is first in, first out / FIFO;
so jobs are printed in the order they were sent / no job is overtaken;
new jobs are added only at the rear;
so it is fair to the people who sent their jobs earlier;
the printer only ever needs the job at the front;
so dequeue gives it the next job directly without searching;
A fitness app stores a user's daily step counts in a list (Python) or array (Java) called steps, holding n values. The app uses the four functions/methods below.
def first_day(steps):
return steps[0]
def total_steps(steps):
total = 0
for s in steps:
total = total + s
return total
def count_beaten(steps):
count = 0
for i in range(len(steps)):
for j in range(len(steps)):
if steps[i] > steps[j]:
count = count + 1
return count
def doublings(steps):
k = 1
count = 0
while k < len(steps):
k = k * 2
count = count + 1
return countpublic static int firstDay(int[] steps) {
return steps[0];
}
public static int totalSteps(int[] steps) {
int total = 0;
for (int s : steps) {
total = total + s;
}
return total;
}
public static int countBeaten(int[] steps) {
int count = 0;
for (int i = 0; i < steps.length; i++) {
for (int j = 0; j < steps.length; j++) {
if (steps[i] > steps[j]) {
count = count + 1;
}
}
}
return count;
}
public static int doublings(int[] steps) {
int k = 1;
int count = 0;
while (k < steps.length) {
k = k * 2;
count = count + 1;
}
return count;
}State the time complexity, in Big O notation, of each of the four functions/methods.
4 marks
Identify which function/method would scale least well as the user keeps recording steps for several years, and outline why.
2 marks
Award [1] for each correct complexity, up to [4 max].first_day / firstDay: ;total_steps / totalSteps: ;count_beaten / countBeaten: ;doublings: ;
Note: Accept for doublings. Accept "constant", "linear", "quadratic", "logarithmic" if clearly matched to each function.
Award [1] for identifying the function and [1] for the outline.count_beaten / countBeaten;
its nested loops each run n times, so the number of comparisons grows with / doubling the number of days multiplies the work by about four;
Note: Allow FT from part (a) only if the function identified has the highest complexity given in (a).
A school library keeps a record of every book it owns. Each book is represented by an object of the class Book.
class Book:
def __init__(self, isbn, title, author):
self.__isbn = isbn
self.__title = title
self.__author = author
self.__on_loan = False
def get_title(self):
return self.__title
def get_author(self):
return self.__author
def is_on_loan(self):
return self.__on_loan
def return_book(self):
self.__on_loan = Falsepublic class Book {
private String isbn;
private String title;
private String author;
private boolean onLoan;
public Book(String isbn, String title, String author) {
this.isbn = isbn;
this.title = title;
this.author = author;
this.onLoan = false;
}
public String getTitle() { return title; }
public String getAuthor() { return author; }
public boolean isOnLoan() { return onLoan; }
public void returnBook() {
onLoan = false;
}
}State the name of one accessor method in the class Book.
1 mark
Construct a statement that creates a Book object for Frankenstein by Mary Shelley, ISBN 978-0-14-143947-1, and stores it in a variable called b.
2 marks
Construct the method check_out() (Python) / checkOut() (Java). If the book is not already on loan, the method marks it as on loan and returns true. If the book is already on loan, it returns false and changes nothing.
3 marks
The library stores its books in a list (Python) / an array of 500 Book references (Java) called books. Unused positions hold None (Python) / null (Java).
Construct the function/method count_available(books, author) / countAvailable(books, author) that returns the number of books by the given author that are not on loan.
5 marks
Explain why the attribute that records whether a book is on loan is private and can only be changed through check_out / checkOut and return_book / returnBook.
3 marks
get_title / getTitle;get_author / getAuthor;is_on_loan / isOnLoan;
Note: Award [1] for any one. Do not accept return_book / returnBook (it changes the state of the object).
Award [1] for each point, up to [2 max].
new object created with the class name (and new in Java) / constructor called;
the three arguments in the correct order (ISBN, title, author) as strings;
result assigned to a variable b (of type Book in Java);
Example answer (Python):
b = Book("978-0-14-143947-1", "Frankenstein", "Mary Shelley")Example answer (Java):
Book b = new Book("978-0-14-143947-1", "Frankenstein", "Mary Shelley");Award [1] for each point, up to [3 max].
checks whether the book is currently on loan (tests the attribute);
sets the on-loan attribute to true only when it was false;
returns false when already on loan and true after a successful loan;
correct method header (Java: public boolean; Python: self parameter);
Example answer (Python):
def check_out(self):
if self.__on_loan:
return False
self.__on_loan = True
return TrueExample answer (Java):
public boolean checkOut() {
if (onLoan) {
return false;
}
onLoan = true;
return true;
}Note: Accept an if/else with a single return of a Boolean variable.
Award [1] for each point, up to [5 max].
correct header with both parameters (Java: int return type, Book[] and String parameters);
counter initialised to 0 before the loop;
loop that visits every element of books;
skips None / null entries (before calling a method on them);
uses the accessor methods to compare the author (Java: .equals) and to test that the book is not on loan;
increments the counter when both conditions hold, and returns it after the loop;
Example answer (Python):
def count_available(books, author):
count = 0
for b in books:
if b is not None and b.get_author() == author and not b.is_on_loan():
count = count + 1
return countExample answer (Java):
public static int countAvailable(Book[] books, String author) {
int count = 0;
for (int i = 0; i < books.length; i++) {
if (books[i] != null && books[i].getAuthor().equals(author)
&& !books[i].isOnLoan()) {
count++;
}
}
return count;
}Note: Accept == for string comparison in Java. Do not award the null-check mark if the null test comes after a method call on the element. Accept a for-each loop.
Award [1] per point, up to [3 max].
private means code outside the class cannot read or assign the attribute directly;
so every change has to go through the class's own methods;
which can apply rules (e.g. a book already on loan cannot be lent again);
this keeps the object in a valid / consistent state (integrity);
other parts of the program do not depend on how the loan status is stored, so it can be changed without breaking them;
Note: The answer must go beyond "it is private so it is hidden" for more than [1].
A music streaming company is designing a new app. Before anyone writes code, the lead developer publishes a description of a Playlist abstract data type (ADT) with these operations:
Operation | Description |
|---|---|
| adds track |
| removes the first occurrence of track |
| returns the track after the one currently playing |
| returns true if the playlist holds no tracks |
Define the term abstract data type.
2 marks
The description does not say whether the tracks are stored in an array or in a linked list.
Outline why the description leaves this out.
2 marks
Explain two benefits to the development team of agreeing the Playlist ADT before the code is written.
4 marks
Award [1] per point, up to [2 max].
A (logical/mathematical) model / description of a data type;
defined by the values it can hold and the operations that can be performed on it;
without specifying how the data is stored / how the operations are implemented;
Note: Do not accept "a data structure" on its own.
Award [1] for the point and [1] for the development.
An ADT separates what the operations do (the interface) from how they are carried out (the implementation);
so programmers using Playlist only need the operations / are not affected by the storage choice;
the implementation can be chosen later / changed without changing code that uses the playlist;
Note: Award [2 max].
Award [1] for a benefit and [1] for a development, x2. Mark the first two benefits only.
Developers can work in parallel / different team members can write the user interface and the playlist storage at the same time;
because each side only relies on the agreed operations / interface;
The storage can be changed (e.g. from an array to a linked list) later;
without rewriting the parts of the app that call addTrack, nextTrack etc. / with less maintenance;
The complexity is hidden (abstraction);
so programmers using the playlist can concentrate on the app's features / are less likely to make errors with the internal data;
The operations can be tested separately;
against the description of what each operation should do, before the rest of the app exists;
The ADT can be reused;
in other apps or features (e.g. a queue of podcasts) that need the same operations;
A free account opens the whole question bank, keeps a record of what you have marked, and builds worksheets from the topics you pick.