IB Comp Sci HL y2 exams 2019
LINKS:  Last Year's Blog   Lewis+Loftus-Java   Java Tutor   Comp Sci Illumin Book 
              Basic Java Lessons   Java OOP   JETS    Internal Assessment Java Notes   Java How-To 
                Vocabulary   IB CS Course Guide     Pseudocode     Notes and Review 2019
  IB Comp Sci Hub
Due Dates :  


   Small Basic sample:

Last Day of Class - 11 Apr 2019

 Here are some suggestions for studying for your exams.
They refer to links in the Review page:

Past Exams - Top section, later exams are 
better than earlier ones, 
use Markschemes to check your answers

Vocabulary - look up unfamiliar vocabulary in :
 Paper 1 Syllabus Notes - directly below the Past Exams
 Read the teacher's explanations in the right column.

 Pseudocode Practice - Pseudocode Practice Tool
 Paper 2 Notes - below Topic 7 

 Standard Java Algorithms - Algorithms.java
 Paper 3 - Case Study

Case Study 2019 - Computer Aided Dispatch System

    Case Study Vocabulary Notes

      A Mock Exam

  ... be sure to re-read the Case Study the night before the exam...

 *** Suggestions ***
- study with a partner, you will help each other learn more
- use pen and paper while studying, to prepare for exams
- use e-mail, or come to room 615, to ask the teacher questions

Textbook - don't read the whole book, focus on the following - 
read quickly and focus on vocabulary
  Ch 1 - 1.1, 1.3
  Ch 2 - All
  Ch 3 - all except compression
  Ch 4 - 4.1, 4.2, 4.4 until p 104
  Ch 5 - 5.1, 5.2     HL = 5.3, 5.4
Ch 6 - 6.5
Ch 7 - All (7.6 is HL only)
Ch 8 - HL only 8.1 - 8.5
          8.7 is for SL and HL
Ch 9 - 9.1, 9.2
Ch 10 - SL - 10.1, 10.2,  
          HL all sections of Ch 10
Ch 13 - Optional and interesting
Ch 15 - All
Ch 17 - 17.2, 17.3

Case Study Long Question - 10 Apr 2019

Here is a mock exam with answer scheme:

Today we will focus on the long question:

=== Long Question (12 marks) ===

The existing CAD system will be updated, while the rest of the Multi-Tier EMIS will be created anew.  

(a) Identify 3 different stakeholder groups who must be studied before development/conversion begins.

(b) For each stakeholder group, discuss how their needs and goals during an emergency

may be affected by their own hardware and software, system infrastructure performance,

and their own personal knowledge and attitudes. 

--- Suggestions for the responses ---

…         USE TECHNICAL VOCABULARY whenever possible and sensible.

…         Your response to this question(s) should be 1-2 pages long, depending on the size of your writing.

…         and it must be completed within 20-30 minutes, as there are other questions on the exam.

…         Hence, you may only give partial responses to each part of the question.

…         Be sure to address ALL parts of the question(s), albeit briefly, rather than one part in depth.

…         Keep in mind that there are no "RIGHT" answers, but there are better and worse answers.

=== IB Official Criteria for the Long Question ===

Case Study Long Discussion Questions - 9 Apr 2019

Paper 3 always ends with a long discussion question.  We will discuss some examples.

Case Study Review - 5 Apr 2019

Case Study 2019 - Computer Aided Dispatch System (pw required)

Case-Study Vocabulary Explanations - by FIS students
Case-Study Vocabulary (private version, pw required) 
Case-Study Vocabulary (public version)

 == Practice ==
 Each student must answer 6 marks worth of questions from 
        below - we will divide them up.
 TYPE your answers at the end of 
Case-Study Vocabulary
 DUE - before 12:00 on Monday 8 Apr  
  On Monday afternoon, the teacher will evaluate
   the answers so we can discuss what makes a 
   good or bad answer - discussion on Tuesday.

 If you finish this early/quickly, you could spend time:
  - re-reading the Case Study
  - re-reading all the Vocabulary notes (above)

Thanks to Matthew Chermside for the following questions:

Comprehension questions

  1. What is the difference between a CAD and an EMIS?
  2. What problem in which part of the system could have caused the police cars to arrive at the wrong address?
  3. What problem in which part of the system could have caused fire engines to be dispatched to a fire that had already been extinguished?
  4. What hardware failures could cause a service to go offline?
  5. How does scalability and extensibility ensure a service is future-proof?
  6. How would a SaaS system be different to a custom-built system?
  7. What is the difference between stateful and stateless communication in distributed systems?
  8. What is the purpose of a load-balancing algorithm?
  9. How could the smartphone app prevent users from uploading trivial data to its ‘inform’ service?



  A.  What is the difference between a real-time system and a transaction processing system 
        and why does the new EMIS require both?
  B.  Are there any minimum hardware recommendations for a certain number of 
        estimated simultaneous users?
  C. Why is an API needed between the Smartphone App and the CAD system?
  D. How does GPS work?
  E. Would the smartphone app work if the users are connected to the Internet through a VPN?
  F. What are the advantages of a multitier architecture?
  G. What advantages does using a cluster of servers at each tier provide for an online service?
  H. What is the difference between HTTP and HTTP2?



i. Discuss what effects could it have on the call-center staff that Rahul is reassigning some of them to different roles, including both positive and negative effects.

ii. Discuss what effects could it have on the call-center staff that Rahul cancelled any future upgrades to the technology the centre uses, including both positive and negative effects.

iii. Discuss what information might be transferred to the EMIS from a smartphone app user’s phone that could personally identify the user, include both positive and negative aspects.

Vocabulary Review - 3-4 Apr 2019

 Old Syllabus Glossary (about 90% useful)

Nov 2018 paper 2 problem #16 - 2 Apr 2019

Stack and Queues - 1 Apr 2019



- push

- pop

- isEmpty

- data

In an array - implementation details

public class Stack


  String[] passengers = new String[1000000];

  int top = -1;

  public Stack()


     top = -1;


  public void push( String name )


     top = top+1;

     passengers[top] = name;


  public String pop( )


     String result = passengers[top];

     top = top-1;

    return result;


  public boolean isEmpty()


     if(top == -1)

     { return true; }


     { return false; }



=== Tomorrow ===

Continue with the Airport program #16

Download a basic working version here

Continue Nov 2018 Paper 2 - 29 Mar 2019

(1) We need to complete this form (each student):
You need to DOWNLOAD the .pdf file,
then use Acrobat Reader to fill in the boxes,
save it on your hard-disk, and then upload it into Haiku.

(2) Continue with the Airport program.
Download a basic working version here:

JETS Programming Constructs - 25-26 Mar 2019

Topics D.3.1 - D.3.10:

We will also be looking at Nov 2018 Paper 2 (you get a paper copy):

Jets Specifications 

public String getETA()


String result = "";

// for example: sta = "13:50" delay = 50 add them

int hours = Integer.parseInt( sta.substring(0,2) );

String mins = sta.substring(3,5);

int min = Integer.parseInt(mins);

int total = min + delay;

if( total > 59)

{ hours++;

int extrahr = total / 60;

int leftoverMins = total % 60;

hours = hours + extrahr;

result = hours + ":" + leftoverMins;

// concatenate

return result;


Study Day - 22 Mar 2019

Please spend today studying - for example:
- Read Chapter 9 in Comp Sci Illumin Book

- Review some past papers in Notes and Review 2019

- If you get bored, you might enjoy these videos:

Topics 10.1.6-10.1.10 - 21 Mar 2019

We will continue discussing OOP in topics 10.1.6-10.1.10

We may discuss the Cafeteria problem on p. 8 of these notes:




int ID = ReadIDcard();

boolean valid = checkIDatBank();



balance = getBalance(ID);


while( !moneyInserted() && cardisPresent() )




money = readMoneyAmount();

double balance = sendMoneyToBank(money);

if( balance = -999999)


giveBackMoney( );





{ output("Error not valid card"); }


OOP Option - 20 Mar 2019

We will begin discussing the OOP Option notes:

In your text-book (Computer Science Illuminated) you should
That explains basic concepts of OOP, as well as Programming Languages in general (Topic 4).
You can read this quickly, without enormous attention to detail.
Find vocabulary you don't understand and ask questions during class.

Parsing Math Formulas with Stacks - 19 Mar 2019

We can use a STACK to help in PARSING a math formula - 
for example, checking whether brackets match sensibly.
- Write a program that inputs a String, presumably containing a math formula,
and check that (parentheses) and [square brackets] match correctly.
This is normally done as follows:
- scan the String one character at a time
- when ( or [ is found, PUSH this onto the STACK
- when ) or ] is found, POP the top item off the STACK
   and check that it matches correctly, e.g. ( and ) , but not  ( and ] 
- if a mismatch occurs, then the formula is NOT VALID
- if the stack .isEmpty, then performing a POP is an error
   and the formula is NOT VALID
- if the String ends and there is still something in the STACK,
    then the String is NOT VALID

The best plan is to write this in Pseudocode, as creating a STACK is easy.
But you will need to use .substring to extract single characters.

Here is a solution that seems to work - you will need to test it thoroughly:

// For example: (2x)^2-1
//                            (2x+1)*(2x+3[x-4]
//                             ]x

STACK = new Stack()

F = input("Formula")

output F


loop X from 0 to F.length-1
    C = F.substring(X,X+1)

    if C = "[" OR C = "(" then
    end if
    if C = "]" OR C = ")" then
                if STACK.isEmpty() then
                       output "Stack empty error"
                       ERRORS = ERRORS + 1
                        LAST = STACK.pop()

                        if NOT(((LAST = "[") AND (C = "]")) OR  (LAST = "(" AND C = ")" ) ) then
                              output "Mismatched brackets :" , LAST , "  ",C
                              ERRORS = ERRORS + 1
                       end if

                end if
   end if

end loop

if NOT STACK.isEmpty() then
     output "Error - stack is not empty at the end, so too many LEFT brackets"
     ERRORS = ERRORS + 1
end if

output "Errors = " , ERRORS


Here is another solution, thanks to Nikita:

F = input("Formula")

I = 0 //If not equal to 0 at the end, part of formula is invalid

STACK = new Stack()

loop X from 0 to F.length - 1
   C = F.substring(X,X+1)
   if C = "[" OR C = "(" then
   end if
   if C = "]" OR C = ")" then
      if(STACK.isEmpty() then
            LAST = STACK.pop()
         if LAST = "(" AND C = ")" then
            // ok
         else if LAST = "[" AND C = "]" then
            // ok
           //Result doesn't need to be pushed back into the stack because
           //if a single mismatch occurs, the formula is definitely invalid
         end if

      end if
   end if

end loop

method invalidInput()

I = I+1

end invalidInput

//If the stack is not empty, invalid.

if NOT STACK.isEmpty() then
end if

if NOT I = 0 then
   output "Invalid input"
   output "Valid input"
end if

output "Left in stack:"
loop while NOT STACK.isEmpty()
   output STACK.pop()
end loop

Trees and LinkedLists - 18 Mar 2019

Here is a project with solutions to all the practice from last class:

We will discuss REBALANCING.

Then begin reviewing STACKS and QUEUES, starting with Mr Brooke's notes (5.1.6 - 5.1.10):
discussing the topics about Stacks and Queues.

Binary Search Trees - 14 Mar 2019

We will use the same program from yesterday
and these notes from previous days

== Counting ==
- Count all the LEAF nodes.  These are all the nodes that
  have no children (null pointers).  This should be done with
  a recursive TRAVERSAL, using a GLOBAL VARIABLE
  to do the counting.

== Searching ==
There are 2 possible ways to search
- If the tree is a proper Binary Search Tree, then the search can be ITERATIVE,
   proceeding down from the root, choosing left or right depending on whether
   the TARGET is larger or smaller than the current node
   This is very similar to adding a new node.

- A total TRAVERSAL, visiting every node in the tree
   This can be a PRE-ORDER, IN-ORDER, or POST-ORDER search
    using a recursive algorithm.  In this case it is not necessary to "sort"
    the items first, but this takes considerably longer.

== Removing a Node ==
- First we must find (search for) the node.
   If it is a LEAF node, it can be "cut off".
   If it is an "internal" node, it is a whole lot more difficult.
   See REBALANCING below.  Removing an internal node
    is done by copying ALL OTHER nodes into a LinkedList,
    and then rebuilding the tree from the LinkedList.

== Rebalancing ==
- The simplest way to rebalance a Binary Search Tree is:
   - Use an IN-ORDER traversal to copy all items into a LinkedList
   - Reconstruct the tree using a Binary Search concept,
      to find the MIDDLE node, add it to the three, and then
      attach the first half to the LeftChild of the root,
      and then attach the second half to the RightChild of root.
      Notice that this should be done RECURSIVELY.

Trees in Java - 13 Mar 2019

Download this sample Trees project.
We will discuss this program in class.

Formula Trees - 12 Mar 2019

Below is a solution for the FACTORING problem.

=== Today = Formula Trees ===
Refer to these notes - on page 3:

We might look at the following Pseudocode algorithm:

// The arrays below represent a formula in a tree.
// The 0 values in the LEFT and RIGHT pointers represent NULL.
// The ROOT is at position 4, so evaluation starts there.
// Local variables A and B need to be marked with "var"
//   so that they are stored locally instead of globally.

VALUES = [0 , 3 ,"*", 4,"/", 2 ,"+", 4]
LEFT   = [0 , 0 , 1 , 0, 2 , 0 , 5 , 0]       
RIGHT  = [0 , 0 , 3 , 0, 6 , 0 , 7 , 0]
ROOT = 4

output "Value = " , evaluate(ROOT)

method evaluate(HERE)
  if VALUES[HERE] = "+" then
     var A = evaluate(LEFT[HERE])
     var B = evaluate(RIGHT[HERE])
     return A+B
  else if VALUES[HERE] = "*" then
     var A = evaluate(LEFT[HERE])
     var B = evaluate(RIGHT[HERE])
     return A*B
  else if VALUES[HERE] = "/" then
     var A = evaluate(LEFT[HERE])
     var B = evaluate(RIGHT[HERE])
     return A/B
  else if VALUES[HERE] = "-" then
     var A = evaluate(LEFT[HERE])
     var B = evaluate(RIGHT[HERE])
     return A-B
     return VALUES[HERE]
  end if

end method

//=== Recursive Factoring Algorithm ===

input NUM


method factor(NUM)
   if NUM < 2 then
      output NUM
   end if

   F = 2
   loop while NOT(NUM mod F = 0)
      F = F+1
   end loop

   if F = NUM then
      output F , " is prime"
      F2 = NUM / F
      output NUM , " = " , F , " * " , F2
   end if
end method


More Searching and Efficiency - 11 Mar 2019

A correct solution to the problem from last class is shown below (2nd program).
A better way to program a Binary Search is by using a recursive method.
Below is an example in Pseudocode.

Now IB Pseudocode actually does not describe a way to write methods,
or any way to use parameters.  Hence, it is basically not possible to
write recursive methods in Pseudocode.  Nevertheless, the IB Examiner
presented a recursive method in a recent IB exam, so it's probably sensible
to learn this anyway.  Try out the program below in Pseudocode.  Then we
will write a couple more recursive examples in Pseudocode.  

Here are a couple common recursive problems:

(0) Towers of Hanoi Interactive

(1) Calculate Factorial (5! = 120) recursively.
      -  0! = 1
      - for larger numbers,  n! = n * (n-1)!
(2) Factoring an integer into prime factors.

(3) Evaluate a mathematical formula stored in a binary tree,
      for example using parallel arrays for storage. 

Here are some notes about binary trees, including storing formulas.

//=== a recursive Binary Search ====

NUMS = [1,3,7,15,31,63,127,255]

input FIND

PLACE = binSearch(FIND,0,7)

output FIND, " found at " , PLACE

method binSearch(TARGET,LO,HI)
   ANSWER = -1
   MID = div(HI + LO , 2)

   if HI < LO then
        return -1
   end if

   if NUMS[MID] = TARGET then
         ANSWER = MID
      else if TARGET < NUMS[MID] then
         ANSWER = binSearch(TARGET,LO,MID-1)
         ANSWER = binSearch(TARGET,MID+1,HI)
   end if

   return ANSWER
end method


Answer from last class is below:


SIZE = 100000
MAX = 1000000

NUMS = new Array(SIZE)
N = 1000000

loop X from 0 to SIZE-1
   NN = random(1,10) + N
   NUMS[X] = NN
   N = NN
end loop

OTHERS = new Array(SIZE)
N = 1000000

loop X from 0 to SIZE-1
   NN = random(1,10) + N
   N = NN
end loop

loop WHERE from 0 to SIZE-1
FOUND = -1
LO = 0

loop while (FOUND = -1) AND (HI >= LO)
   MID = div(HI + LO , 2)
   if OTHERS[MID] = TARGET then
         FOUND = MID
      else if TARGET < OTHERS[MID] then
         HI = MID-1
         LO = MID+1
   end if
end loop

if(FOUND >= 0)
   output TARGET, " found in locations ", WHERE, " and ", FOUND
end loop

output "== All Values =="
loop X from 0 to SIZE-1
  output X, " = ", NUMS[X], "     ", OTHERS[X]
end loop

method random(smallest, largest)
   // creates a random number between smallest and largest-1
   return Math.floor(Math.random()*(largest-smallest)) + smallest
end method


A shorter, and hence simpler, version of a Binary Search is recursive.

Binary Search - 8 Mar 2019

We will start with the program below, and then write a Binary Search.

This program creates two Arrays NUMS and OTHERS and fills them with random numbers.
The random numbers in each list are in increasing order, sorted from smallest to largest.
This simulates two lists of telephone numbers.

The question is whether there are any DUPLICATE numbers.
This might be interesting for a police agency that has collected lists of phone numbers
for two different companies, and is looking for a phone number that called BOTH of them.

In real life, things would not be this simple, as the phone numbers would not be sorted.
We can assume they collected the numbers and already sorted them.

Now we need to write code that searches for duplicates in the two lists.


SIZE = 100000
MAX = 1000000

NUMS = new Array(SIZE)
N = 1000000

loop X from 0 to SIZE-1
   NN = random(1,10) + N
   NUMS[X] = NN
   N = NN
end loop

OTHERS = new Array(SIZE)
N = 1000000

loop X from 0 to SIZE-1
   NN = random(1,10) + N
   N = NN
end loop

FOUND = -1

loop X from 0 to SIZE-1
   if OTHERS[X] = TARGET then
       FOUND = X
   end if
end loop

output TARGET, " found in location ", FOUND

output "== All Values =="
loop X from 0 to SIZE-1
  output X, " = ", NUMS[X], "     ", OTHERS[X]
end loop

method random(smallest, largest)
   // creates a random number between smallest and largest-1
   return Math.floor(Math.random()*(largest-smallest)) + smallest
end method

Random Numbers in Pseudocode - 7 Mar 2019

Copy this algorithm into the Pseudocode simulator.

This program is similar to LOTTO.

The program chooses a random number between 1 and 20, 
and repeats this 10 times.  It stores each random number
in the NUMS array.  Then you get 3 guesses at the numbers.
If you get lucky 3 times, you are a WINNER.

Run the program several times.  Keep track of how many WINNERS you get.

Change the program to only choose 5 random numbers.
That will make it harder to get WINNER.

Experiment to find out how many random numbers are required
to get a 50% chance of being a winner.

This is all a bit complicated, because some of the random numbers
are duplicates, so we don't really know how many targets are in the array.
Change the program so that it does not choose duplicates.
Then repeat your experiments.


MAX = 20
NUMS = new Array(MAX)


loop X from 1 to 10
   N = random(0 , MAX)
   // creates a random number between 0 and MAX-1
   NUMS[N] = N
end loop

loop X from 1 to 3
  input GUESS
  if NUMS[GUESS] = GUESS then
     output GUESS, " RIGHT"
     output GUESS, "no"
  end if
end loop

if CORRECT = 3 then
   output "WINNER"
end if

output "== All Values =="
loop X from 0 to MAX-1
  output X, " = ", NUMS[X]
end loop

method random(smallest, largest)
   // creates a random number between smallest and largest-1
   return Math.floor(Math.random()*(largest-smallest)) + smallest
end method

Now we need to write a couple more algorithms.
You can write these directly in the Pseudocode emulator.

*** NOTICE *** 
 You cannot trust the [Save] button. You can save your program
 by marking all the text, copying it, and pasting it into a document
 that you can save.

- Write a loop to fill an array of size 10 with random numbers.
   Each number should be 3 digits - between 0 and 999.

- Write a loop to add up the random numbers in the array.
- Make the program repeat 10 times, and each time make
   new random numbers and add them up.  The result will be
   10 TOTALS.  They will be reasonably close to each other.
    A total of 20 is highly unlikely, although not impossible.

- Make the program repeat 1000 times instead of 10.
   It should ADD UP all the TOTALS and display the following:
   (a) the average TOTAL
   (b) the smallest TOTAL
   (c) the largest TOTAL
   (d) the difference between smallest and largest = RANGE

Sorting and Binary Search - 6 Mar 2019

A school maintains a list of student NAMES in an array,
and the AGES of the students in a PARALLEL ARRAY.

Assume that the school is just starting to register students for a new school year.
The first 7 students walk in the door in the following order:

NAMES = ["Al","Carla","Eve","Greg","Fred","Dee","Bobo"]
AGES = [10,12,15,14,16,13,11]

(a) Write the NAMES in order of ages, from youngest to oldest.

(b) Construct a Pseudocode algorithm that prints the names of all the students
      who are 14 years or older.

(c) Construct an algorithm that prints all the names and ages where
      the name begins with "Gr".

(d) In Pseudocode, construct an algorithm that inputs a student NAME
and searches for that NAME in NAMES.  If it finds the NAME,
it should output the corresponding AGE.  If not found, it should output -1.

(e) Later, the school has 3000 students registered.  A secretary wishes to
search for the name "Cholmendely" (pronounced Chumley).  
After 3 unsuccessful tries, he realizes that he is not sure how to 
spell this name.  After outputting ALL the names, he realizes it is just a big mess.  

  (i) Construct an algorithm that sorts the names into alphabetical order.
       It must also rearrange the AGES so they still match the correct NAMES.

  (ii) If there are 3000 names, estimate the number of ITERATIONS
       to sort the arrays.

(f) Explain why a BINARY SEARCH cannot be used to search for a name
     before running the sorting algorithm.

(g) Write a BINARY SEARCH algorithm to search for a NAME and
      output the corresponding AGE, or -1 if not found.

Practicing Pseudocode - 1-4 Mar 2019

Here are some questions from OLD exams (around year 2000).
These are all about Pseudocode.  The Pseudocode back then was
slightly different from our current Pseudocode, but these are
still good practice questions.  You should:

1 - read a questions
2 - write a solution on paper, with a pen
3 - compare your solution to the solution in the document
4 - if appropriate, type your solution into the practice tool : 

Then do another question.  Working with another student
is quite useful.

Begin Review and Finishing Syllabus - 25-27 Feb 2019

We will discuss 2017 Paper 1:

Nov 2017

IA Forms Folders - 11-15 Feb 2019

The teacher will distribute USB sticks to each student,
including a FORMS folder as specified by the IBO.

Please note the following advice:
0 - all files in the Documents folder must be PDF files
     The links on the cover-sheet are correct, IF you name the files correctly
1 - you need to use a Web-Page editor (Seamonkey or Kompozer) to edit the CoverPage
     If you use MS Word (DON'T) it makes a mess of the file
2 - don't forget to include a sound-track (narration) with your video
     The video should be 5-7 minutes long
3 - show your finished program to your client and include some of their suggestions
       in Stage E Evaluation
4 - Don't forget the Record of Tasks
5 - You can make an EXECUTABLE .jar file in NetBeans:
      - Click on [Run][Clean and Build Project]
      - link the cover sheet to [dist][filename.jar]
6 - you may find this check-list helpful:  Checklist (IBO)

You may spend the classes this week finishing your IA.
If you finish early, you can do work for another class.

You need to turn in the USB stick containing all files and the program on
     Friday 15 Feb

Work on IA - 7-11 Feb 2019

Remember that your Internal Assessment is due on Friday 15 Feb.
We will spend class time working on this Thursday, Friday and Monday (11 Feb).
If you are uncertain about how much to write in Stage C documentation,
or exactly how to create your video for Stage D, this is your opportunity to:
ask questions and get help.

On Tuesday you will receive a USB stick with a standard Forms Directory.
You will need to copy all your PDF files (and your Java program) into the standard
folders provided, then submit the USB stick to the teacher on 15 Feb.
Since class does not meet on 15 Feb, you may submit your IA project
on 14 Feb, or during lunch or after school on 15 Feb - but no later than 15:30 on Friday.  

More Trees - 6 Feb 2019

We will continue discussing this tree program (PhoneTree):

Open PhoneTree.

We will add a few more methods, like:
- Change a Phone Number
- Remove a Leaf Node
- Remove an Internal Node by re-building the tree

Mock Exam Paper 2 #4 - 5 Feb 2019

Here is a program for solving problem #4:

We will review TREES and add more methods to this program.

Arrays and LinkedList Practice - 1 Feb 2019

The main difference between LinkedLists and arrays are:
(1) Dynamic vs Static
(2) Methods vs no methods
** Explain these **

Programmers like LinkedLists if they need to INSERT or DELETE data items.
They like arrays if they are counting or adding up items.

Suppose you have an ARRAY that contains RECORDS (Objects) with a NAME and AGE in each one.
Assume the array is already sorted alphabetically by NAME.
Write Java to insert a new name in the alphabetically correct place, but do it like this:
- copy the entire array into a LinkedList
- INSERT the new name into the LinkedList
- make a NEW ARRAY and copy the LinkedList into the array

It can start out like this:


class Person

String name = "";
int age = 0; 

  public Person(String name, int age)




Person[] data = {new Person("Al",10),new Person("Bee",15), new Person("Kim",12),new Person("Nel",18),

new Person("Pete",15),new Person("Zeke",99)};

LinkedList<Person> list = new _____________________________

public void insertMickey()

   Person p = new Person("Mickey Mouse",80);





public void showArray()



    for(int x = 0; x < data.length; x++)




public void copyArrayToList()


    for(int x=0; x < data.length; x = x+1)






public void insertIntoList(Person m)



public void copyListToArray() 


    for(int x = 0; x < list.size(); x = x+1)





private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {



private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {




Obviously INSERT-INTO-LIST at position 4 all the time is a bad idea.
This needs to be rewritten, to be a loop that searches for the
correct position, where M belongs after X and before X+1.
Then it should be able to insert ANY NAME correctly.

String Practice - 31 Jan 2019

Since there are so many absences, we will do some simple
String practice at Codingbat.com:

OOP Review - 30 Jan 2019

We must review Mock Exam Paper 2 and spend some more time
practicing OOP programming - but this time on paper, with a pen.

Mock Exam Paper 2 : 


== String Methods ==

+ for concatenation 
.substring(startPos, endPos) 

Mock Question 3c

Finishing the IA - 28-29 Jan 2019

Here are the rest of the steps for finishing your IA.
The order doesn't matter, but the stated order probably makes sense.

Record of Tasks -
  Make sure that your Record of Tasks (weekly entries)
  is up-to-date.  If not, add entries so that you have about one per week.

  A TEST PLAN is a requirement.  Look at the examples in Stage B of:
  You must ADD the test plan to your Stage B document - 
   it's a requirement.  Make a TABLE with columns for : 
       [Action to Test]     and      [Method of Testing and Results]
   Be sure that your tests cover EVERY GOAL / CRITERION FOR SUCCESS, 
    including methods that implement AUTOMATION without any apparent visual interface.

Stage D - VIDEO
   Your video must demonstrate ALL THE SIGNIFICANT FEATURES.
   The video must clearly demonstrate that ALL THE FEATURES FUNCTION WELL.  
    This must also be stated in Stage E.

   You must write DOCUMENTATION of how your program was written.
   This generally includes a Screen-Shot, some Java Code,
     and a brief (one or two sentence) explanation of how the code works.
     There needs to be at least one entry for every significant feature -
       especially anything that was difficult or complex to write.

Stage E - Evaluation (more on this later)

Cover Page - later

It is QUITE POSSIBLE that you will discover BUGS during the testing,
so it's best to write the TEST PLAN and do the tests BEFORE you 
decide the program is really complete.  Making the video will 
probably help in thinking about the testing.  You really need to
have the program FINISHED before writing the documentation in
Stage C.  Do the Evaluation last - it doesn't take long.

== Project Folder == 

The entire project is due on 15 Feb.  Make sure that all the documents
are PDF files, and that the Video is a standard format.  We will discuss
the formatting of the Project FOLDER and documents on 11 Feb.


Preparing for Mock Exams - 26-30 Nov 2018

Here are some suggestions for preparing for your Mock Exams:

- Old mock exam from Dec 2017:
  Paper 1 : http://ibcomp.fis.edu/2017/mockDec2017/mockP1HL2017.pdf

- Old mock exam from Dec 2014:

- Old mock exam review from 2013:

Notes and Review 2019 - past exams from 2014-2017
   You can use the past papers to practice for Paper 2 OOP Java.


Past Paper 2 - OOP - 19-21 Nov 2018

Sorting - 16 Nov 2018

Download this program, then do the following:

- run it and test that it works correctly

- increase the amount of sample data to 20 items

- load the sample data an then add 2 new reservations and sort the result,
    checking the the sorting works correctly

- add another button that SORTS ROOMS - so it sorts all the reservations
   in order of the room numbers

- add another button that SORTS NAMES - so it sorts all the reservations
   in order of the customer name

- try pressing the 3 Sort buttons in various orders -
   that should produce a variety of results

Continue Hotel OOP Program - 14 Nov 2018

We will discuss this program:
Specifically, we will add a SORTING method for the reservations.

Finishing/Reviewing OOP - 13 Nov 2018

The Paper 2 exam will be about Object Oriented Programming.  We need to learn a bit more about vocabulary and details to prepare for the Mock Exam in December.

Example UML Class Diagram

== HOTEL Example ==

A hotel management system must fulfill at least the following goals:
- records reservations
- checks-in customers when they arrive
- assigns an empty room when a customer checks in
- checks-out customers when they leave
- prints a bill when a customer checks out
- SEARCHes for specific info, like "who is in room 12"
   or "what room is Ronald MacDonald in"
- SORTS data and displays it, for example:
   - all the names currently staying in the hotel
   - a list of empty rooms right now
   - a list of empty rooms on a future date

Here is a very basic PROTOYPE:

   Hotel hotel = new Hotel();
   private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {                                        
       String name = input("Customer name");
       int room = Integer.parseInt(input("Room number"));
       String start = input("Starting date");
       String end = input("Ending date");
       for(int x=0; x < 1000; x=x+1)
           if(hotel.reservations[x] == null)
               Reservation res = new Reservation();
               res.customer = name;
               res.room = room;
               res.arrive = start;
               res.depart = end;
               hotel.reservations[x] = res;

   private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {                                        
       for(int x = 0; x < 1000; x = x+1)
           if(hotel.reservations[x] != null)
               Reservation res = hotel.reservations[x];
               output(res.room + ":" + res.customer);

 static String input(String prompt)
 { return javax.swing.JOptionPane.showInputDialog(null,prompt); }

  public void output(String message)
  {  javax.swing.JOptionPane.showMessageDialog(null,message);  }


public class Hotel {
   Reservation[] reservations = new Reservation[1000];


class Reservation
  String customer;
  int room;
  String arrive;
  String depart;

Last Day in Class Working on IA - 12 Nov 2018

Today is the last day in class working on your IA Project program.
A working version (not finished, but working) is due :
Wed 21 Nov - Preliminary Working Version of IA Program due

This must be turned in as a .zip archive containing your ENTIRE program,
including any sample data files.

Starting tomorrow we will REVIEW and FINISH OOP,
so you are prepared for Paper 2 of your Mock exam.

Continue Working on IA Program - 6-8 Nov 2018

It might be a good idea to update your Record of Tasks.

If you get "stuck", you NEED to ask a question, resolve the problem,
and continue making progress.

Case Study Test - 31 Oct 2018

50 min test about the Case Study.
You will receive a printed copy of the Case Study
to use during the test.

Continue IA Project - 29-30 Oct 2018

Continue working on your Java program for the IA Project.

Be sure to write an entry in your Record of Tasks.
This should be a programming goal, like :
"saving data on the hard disk"
"laying out the user-interface"
Make a realistic plan for completing this, like 2 days or a week.

Continue IA Project - 26-30 Oct 2018

Continue working on your Java program for the IA Project.

Re-starting Your Project Program - 25 Oct 2018

Compare your answers to yesterday's practice questions to these sample answers:

Now it is time to re-start (or continue) your IA Java Project.
You should try to use the ideas that you have prepared in Stage B.

Plan on continuing programming in class tomorrow and Tuesday.

Practice Exam Questions - 24 Oct 2018

We will have Case Study Test on Wed 31 Oct.

Here are some practice questions about the Case Study.  
You should discuss these with another student, write good answers
(hint: for 4 marks, you need to say at least 4 significant things)
and you can compare your answers to the teacher's answers tomorrow.

1.  Explain 2 important reasons that Bangbai wishes to replace their CAD
     system with a new EMIS system.  You must EXPLAIN the reasons -
     for example, if you state that "the CAD uses old technology", you must
     EXPLAIN why this is a problem.                  [4 marks]

2.  Describe 2 advantages and 2 disadvantages of depending on
      modern Smartphones rather than depending on old-fashioned 
      wired telephones.                                        [4 marks]

3.  (a) Discuss 2 important advantages of using a Multitier Architecture
          in the new EMIS, as opposed to wrapping all functionality into
          just a few standard Java applications/apps.              [4 marks]

     (b) Explain which TIER of the Multitier architecture would implement
           a FAIL-OVER system, including WHY this is important.   [2 marks]

4.  Describe how the EMIS can properly handle URGENT vs NON-URGENT
     emergencies, especially how the DECISION would be made about
     the level of urgency.                                                        [4 marks]

5.  Describe the need for compatibility between the old CAD system
     and the new EMIS system, including:
     - ethical considerations
     - technical issues
     - reliability                                                                        [8 marks]

6.  Describe 2 possible approaches to LOAD-BALANCING, including:
     - when/why load-balancing is necessary
     - how each of your approaches will perform better than alternatives
     - what technical requirements must be met in order
        to implement each approach                                       [6 marks]

7.  Explain the difference between STATEFUL and STATELESS
     communication, including an example of where each 
     commonly occurs.                                                           [4 marks]

Vocabulary Discussion - 22 Oct 2018

We will discuss the vocabulary you researched, and especially any QUESTIONS
that students have.

Continue Vocabulary Review - 19 Oct 2018

Continue reading the Case Study carefully, concentrating on the 
vocabulary words marked in italics and listed at the end.

For each word, answer the questions:
- explain what the term means
- explain why it is important for the Case Study EMIS

You can start with the Case-Study Vocabulary,
and use the Web for more information:
-  Google search
-  Wikipedia
-  the links listed in the Case Study

Write down notes and we will begin discussing your answers
next week.

Finish Stage B Draft - 18 Oct 2018

Today you may continue your Case Study Vocabulary Review,
or finish your Stage B document if you prefer.

Whatever you have finished for the Stage B, you need to turn
it in to Haiku today, as Mr Mulkey must read and mark these
and then write report cards on the weekend.

Case Study Vocabulary  - 17 Oct 2018

Example questions:
- Explain what REST means, and why it is important for an EMIS.
.... replace REST with any other vocabulary, making lots of questions.

More About APPS - 16 Oct 2018

Can we base an Emergency Management Information System on APPS?
- how do apps work?
- are they reliable - if not, what causes unreliability?
- are the cheap? Are they easy to distribute?
- are APPS mentioned in the Case Study?
   Case-Study Vocabulary 
- can we make a Data-Flow-Diagram for apps?
   It should clearly illustrate DEPENDENCIES

Apps for Emergencies - 15 Oct 2018

We will discuss this news article:

Here are some other web-sites about emergency apps:

Case Study - Infrastructure - 12 Oct 2018

What INFRASTRUCTURE is required for a proper Emergency Management Information System - especially COMMUNICATIONS?
Consider all the following technical devices and discuss the required infrastructure and how it can fail,
and draw a Data Flow Diagram on paper, with a pen.
- radio . -  did this in class
- television .  Luke + RJ
- signs .     Sean + Axel
- phones .   Mulkey + alone 
- cell phones and Smartphones .   Nikita + Kartik
- email .  Delphine + Rudra
- instant messaging (Twitter, Facebook, Whatsapp, etc) . Jin Woo + Jonathon
- satellites . - actually supports the other devices

Especially consider the questions of:
- broadcasts vs point-to-point
- push vs pull technologies

Case Study - False Alarms, an Ethical Issue - 10 Oct 2018

A False Alarm is a noise or message that indicates that something is wrong,
when in actual fact nothing is wrong.  False Alarms can cause all kinds of problems -
- unnecessary panic
- accidents when people are trying to escape
- financial damage when people stop working
- dangerous or counterproductive reactions
- waste of costly resources
- reduced confidence in the warning system, and hence reduced usage

In case a central warning system is deployed, it is essential that false alarms
must be minimized - but how can this be accomplished without simply
shutting down the system?

Here are a few example news stories:

Turning in Stage B Draft - 8-9 Oct 2018

On Oct 18, a DRAFT of Stage B - Design is due.
This should NOT include a TESTING plan.
It need not be "complete", but must demonstrate a thorough
start on all of the following parts:

(1) Record of Tasks - all task accomplished between May 
  and Sep (including an entry about completing Stage B Draft)

(2) ONE system OVERVIEW diagram,
     which could be displayed as any of the following:
   - top-down hierarchical chart
   - UML class diagram
   - Data-Flow-Diagram showing how data flows between modules,
     including text files, arrays, screen displays, and other variables
     DFD Introduction --> 

     We will discuss these notes:

(3) "screen-shots" from your Visual Prototype (or further
     additions) - at least 5 "screen-shots"

(4) algorithms that will implement interesting automation
     (at least 3 algorithms) - algorithms may be displayed as:
     - Pseudocode 
     - or  Flow-charts (example)    
     - Java (maybe from the Functional Prototype)
  In each case the algorithm must be clearly explained

The teacher will show examples of each of these.

Remembering the Case Study - 26 Sep 2018

Here are some videos of examples of existing Emergency Management Systems -

RISK Communication Video : https://youtu.be/TDX3m20u0Nw

ATOS Call Centers: https://youtu.be/CzXJh6CFK7k

Continue Stage B - 24-25 Sep 2018

1.  Make sure you have started your Record of Tasks document -
     that you have made the first 4 or 5 entries, including:
     - choosing a problem and a client
     - Visual Prototype
     - Client interview
     - Functional Prototype
     - Stage A

2.  Here is a brief explanation of UML diagrams:

3.  Here is a Diagram Editor for Flowcharts and UML:

4.  Here is a sample UML diagram for an attendance program:

5.  If you have not yet done so, show your initial overview to the teacher

UML Diagrams - 21 Sep 2018

UML = Unified Modeling Language

This provides diagrams that clearly illustrate the connections
between MODULES in a system.

If you use OBJECTS and CLASSES in your project,
you should include a UML chart, like this:

That shows the following:
- data members (variables/properties) of each object
- method members of each object
- BasicPart and CompoundPart both EXTEND (isA) Part
- CompoundPart must CONTAIN (hasA) 2 or more parts

Here is another simple example:

Here is one more example - you are unlikely to have so many classes:

Notice that this only has class boxes, without arrows.
This is sufficient for an IB IA Project.

Record of Tasks - 19 Sep 2018

 Due Date :  Stage B partial (no testing) - 18 Oct at 18:00

For your Internal Assessment Project, you are required
to keep a journal of all your work.  
This is called the "Record of Tasks".
You will find this in the Documents folder in the following link;

Starting Stage B - 18 Sep 2018

Networks Test - 17 Sep 2018

You may use the entire class period for the test.

More About Networks - 13-14 Sep 2018

We will discuss the questions at the end of Chapter 15:

Network Exam Questions - 11-12 Sep 2018

Several students neglected to submit the APPENDIX containing
notes of the Client Interview.  Those students need to add
this appendix and resubmit the Stage A document -
submit this no later than 17 Sep.  Any students who wish
to make other improvements may also resubmit the document
and possibly receive a better grade.

Questions - 31 Aug 2018

We will discuss the answers to questions 1-11,
then discuss the rest.

How Data Moves Around - 30 Aug 2018

=== Homework ===
Questions 1-11, one answer from each student, 1 paragraph each:

*** Remember that Stage A is due 31 Aug ***

Today: Follow data in the web

Questions about networks:

Networks - Section 3 in IB Syllabus - 20-24 Aug 2018

Reading :  Read Chapter 15 NETWORKING (p717) in your textbook Computer Science Illuminated

A good overview in a Video:

IB Notes :  Topic 3 - Network Basics  with brief explanations and questions

Some informative videos:
Basics of Protocols (first half)
Internet of Things Part 1 . Part 2  Part 3Part 4 . Part 5 . (you need not watch ALL of these)
Google Data Center (start in the middle)

About DNS
Google: [which ip addresses are local]

Future Networks

Internet of Things, 5G, better BlueTooth, Network Neutrality,  NFC = Near Field Communication = Contactless Credit Card readers


100 Questions and Answers

Continuing Stage A - Planning - 15-16 Aug 2018

It is time to write the first OFFICIAL part of the IA Project - Stage A.

  Stage A : due on Fri 31 Aug at 18:00

This is the easiest part of the IA Project. Don't turn it into something difficult.
It is 500 words - e.g. less than 2 pages.
The teacher will show you examples and outline what pieces are needed.

Read these notes:  

For Stage A, focus on :
- Choose a CLIENT and TALK TO THEM

- DEFINE the problem by :
  - referring to specific User Stories and Client Requests
  - show SAMPLE DATA and/or PICTURES of current solutions
  - include your VISUAL PROTOTYPE in the appendix if you wish

- EXPLAIN the REASONS for your proposed solution, especially
  - a picture of your VISUAL PROTOTYPE
  - AUTOMATION that will make things better for the client
  - REQUIREMENTS and/or LIMITATIONS (more on this in the goals)

- write GOALS (Criteria for Success) that are:

  - clear
  - precise
  - testable
  - complete
  - written as a BULLETED LIST

- Put notes from your CLIENT interview in the APPENDIX
- If you want, put USER STORIES in the APPENDIX

- keep the total word-count under 500 words
   only "extended writing" counts - that means paragraphs 
   bulleted lists don't count 
   diagrams don't count
   the appendix doesn't count

Here is a good example that would receive 6/6 marks for Stage A:

Look at the Student Work - Planning section
You can IMITATE this, but do NOT COPY IT exactly
For example, if you write reasons for choosing Java,
don't write the same reasons that the author wrote.

Here is another good example :
   Example 6  Stock Control System

You may wish to look at the Assessment Criteria:

This CHECKLIST might also be useful:


input NUM

ANS = fact(NUM)

output "Factorial = " , ANS

input NUM


method fact(NUM)

   output NUM

   if NUM = 0 OR NUM = 1 then

      return 1

   end if

   return NUM*fact(NUM-1)

end method

method factor(NUM)

   if NUM < 2 then

      output NUM


   end if

   if NUM < 2 then

      output NUM , " is prime"


   end if

   F = 2

   loop while NOT(NUM mod F = 0)

      F = F+1

   end loop

   if F = NUM then

      output F , " is prime"


      F2 = NUM / F

      output NUM , " = " , F , " * " , F2



   end if

end method