4.1 General Principles (10 Hours) : Pseudocode
4.1 General Principles (10 Hours) : Pseudocode
Thinking procedurally
4.1.1 Identify the procedure 2 This includes identifying the steps This means to write a set of steps for an ALGORITHM
appropriate to solving a and putting them in the correct order. that solves a problem reliably. These could be written in
problem. Such as recipes, block-arrow-block- PSEUDOCODE or in a FLOW-CHART.
arrow. For example: Add up all numbers from 1 to 99
LINK Connecting computational SUM = 0
thinking and program design, loop NUM from 1 to 99
introduction to programming. SUM = SUM + NUM
end loop
output SUM
4.1.2 Evaluate whether the 3 Links to problems presented to the This means TESTING an algorithm using SAMPLE DATA.
order in which activities student in other areas of the syllabus. For example, the following should add up all positive
are undertaken will result LINK Thinking ahead, thinking numbers in an array containing 5 numbers.
in the required outcome. concurrently. Connecting Test with NUMS = [ 5 , -5 , 0, -2 , 2 ]
computational thinking and program loop C from 0 to 4
design, introduction to programming. SUM = 0
MYP Technology, step-by-step SUM = SUM + NUMS[C]
instructions. end loop
---> answer : result is SUM = 2
but it should produce SUM = 7
The SUM = 0 command should be before the loop command
4.1.3 Explain the role of sub- 3 Constructing procedures that can If the programming language provides pre-written procedures,
procedures in solving a then be referred to by their identifier. then the algorithm can execute a pre-written command
problem. LINK Abstraction, connecting instead of the programmer writing lots of code.s
computational thinking and program For example, if the language contains a SUM command for
design, introduction to programming. adding up an array, then it's not necessary to write a loop.
Instead, just write : ANSWER = SUM(NUMBERS)
Thinking logically
4.1.4 Identify when decision- 2 Links to procedural thinking— In PSEUDOCODE, decisions are written as IF...THEN…
making is required in a alternative procedures. In FLOW-CHARTS, use a Diamond to represent a decision.
specified situation. TOK Reasoning as a form of
decision-making.
LINK Connecting computational
thinking and program design,
introduction to programming.
4.1.5 Identify the decisions 2 Different actions are taken based on Common decisions are:
required for the solution conditions. Strings : if ANSWER = "YES" then…
to a specified problem. LINK Connecting computational Numbers : if AGE > 21 then …
thinking and program design, Boolean : if FOUND = TRUE then ...
introduction to programming.
AIM 4 Applying thinking skills to
identify and resolve a specified
complex problem.
4.1.6 Identify the condition 2 Testing conditions, iteration. Compound BOOLEAN conditions us AND, OR, NOT
associated with a given Identifying and constructing the For example :
decision in a specified conditions—AND, OR, NOT if AGE >= 13 AND AGE <=18 then
problem. relationships—Boolean tests. SCHOOL = "High School"
LINK Connecting computational end if
thinking and program design,
introduction to programming. if TODAY = "SAT" OR TODAY = "SUN" then
output "Weekend"
end if
4.1.8 Deduce logical rules for 3 LINK Connecting computational For example, in a black-jack game:
real-world situations. thinking and program design,
introduction to programming. if MYTOTAL = 21 AND MYCARDCOUNT = 2 then
output "I win"
else if MYTOTAL > 21 then
output "I Lose"
else if DEALERTOTAL > 21 then
output "I Win"
else if MYTOTAL > DEALERTOTAL then
output "I Win"
else
output "I Lose"
end if
Thinking ahead
4.1.9 Identify the inputs and 2 This is connected to TESTING - For example:
outputs required in a a TEST-CASE must specify Algorithm should ADD UP all positive numbers in an array
solution. the expected INPUT and the Test Case A
required OUTPUT Input = [ 5 , -2 , 0 , -5 , 3 ]
Output = SUM = 8
Test Case B
Input = [ -1 , -2 , -3 ]
Output = 0
4.1.10 Identify pre-planning in a 2 Gantt charts. Gantt Chart - for project planning
suggested problem and Pre-ordering. Pre-heating an oven.
solution. Home/locker/knapsack.
Caching/pre-fetching. Building
libraries of pre-formed elements for
future use.
LINK Thinking procedurally, thinking
concurrently. Connecting
computational thinking and program
design, introduction to programming.
4.1.13 Identify exceptions that 2 For example, identify the pre- For example:
need to be considered in conditions for calculating the end-of-
a specified problem year bonus when not all employees (a) Solving Ax^2 + Bx + C = 0, there is NO SOLUTION
solution. have worked for the company for the if B^2-4AC < 0 - that's an exception
whole year.
LINK Connecting computational (b) When searching in a Linked-List, it could happen
thinking and program design, that the HEAD pointer is NULL. Then the search
introduction to programming. must end immediately, returning NOT FOUND
Thinking concurrently
4.1.14 Identify the parts of a 2 Could include computer systems or For example :
solution that could be real-life situations. We cannot SEARCH an array at the same time
implemented LINK Thinking ahead, thinking that a different algorithm is SORTING the array
concurrently. procedurally. Connecting But:
computational thinking and program We can ADD UP all the numbers in an array
design, introduction to programming. at the same time that a different algorithm
is searching for the largest and smallest values,
and a third algorithm is copying all the values from
the array into a TextArea on the computer screen.
4.1.15 Describe how concurrent 2 For example, building a house, Algorithms are not required, but a Gantt chart
processing can be used production lines, division of labour. would be appropriate. Concurrent processes are
to solve a problem. Students will not be expected to are the ones with bars that overlap.
construct a flow chart or pseudocode
related to concurrent processing.
4.1.16 Evaluate the decision to 3 LINK Thinking ahead, thinking Concurrent processing makes sense when it is possible
use concurrent procedurally. Connecting to use multiple devices simultaneously, hence reducing
processing in solving a computational thinking and program the amount of time required.
problem. design, introduction to programming.
Usually, WRITE commands cannot be done concurrently
with anything else, whereas READ commands can be
done concurrently.
Thinking abstractly
4.1.17 Identify examples of 2 Selecting the pieces of information Abstraction means simplifying reality so that it can
abstraction. that are relevant to solving the be represented (stored) inside a computer. For example,
problem. a road map can be represented with codes for the starting
LINK Thinking ahead. and ending points of the road, plus a number that tells
the length of the road. It is not necessary to actually have
a picture of the turns in the road. A famous problem is
the Bridges of Koenigsberg, where only the starting and
ending points are saved.
4.1.18 Explain why abstraction 3 Students should be aware of the In addition to encoding data items, for example as numbers,
is required in the concept of objects, for example, the DATA-STRUCTURES provide a chance to represent
derivation of use of collections as objects in the RELATIONSHIPS between data items. For example,
computational solutions design of algorithms. an ARRAY or a LINKED-LIST can record data items
for a specified situation. LINK in a specific order. A TREE can save a HIERARCHICAL
● Databases: tables, queries STRUCTURE - for example representing a mathematical
● Modelling and simulation: an formula or a directory tree. But neither a LIST nor a TREE
abstraction of reality can correctly represent the WEB, which has arbitrary
● OOP: classes, sub-classes numbers of links from any node, as well as links going
● Web science: distributed in both directions between nodes.
applications
4.1.19 Construct an abstraction 3 There is no need to use code. This might be done using a DIAGRAM,
from a specified Levels of abstraction through like a tree with lines linking nodes together.
situation. successive decomposition. Or a 2-dimensional array (table).
A school can be decomposed into
faculties. A faculty can be
decomposed into departments.
LINK Thinking ahead, thinking
procedurally. Connecting
computational thinking and program
design, introduction to programming.
4.1.20 Distinguish between a 2 TOK The map as an abstraction of For example, an ID number for a student and the student's
real-world entity and its the territory. NAME are not the same as the actual student. Usually,
abstraction. abstractions only represent part of the important data. A student
also has a birthdate, a phone number, height, weight,
nationality, etc. Even with all that data, we still would not have a
PICTURE of the students face, and we would not know
what they ate during the past week.
4.2.1 Describe the characteristics 2 These are: sequential search, Sequential Search
of standard algorithms on binary search, bubble sort, Start at the beginning
linear arrays. selection sort. Check each position in the array
If target item is found then
output POSITION where item was found
else
move to next item
Binary Search
Start in the middle of the array
if target item is found then
output POSITION where item was found
else if target < current item then
start again in the middle of the first half of list
else
start again in the middle of the 2nd half of list
Bubble Sort
N = number of items in the array
Search through entire list N times
At each position, compare DATA[X] to DATA[X+1]
swap items X and X+1 if they are not in order
continue to end of list
Next pass
Selection Sort
find BEST item in list
swap it to beginning of list
find BEST item starting in second position
swap into 2nd position
repeat at 3rd position, then 4th position, etc
Requires N passes, but each pass is 1 item shorter
4.2.2 Outline the standard 2 These are: addition and retrieval of A collection is an UNORDERED list of data - a "SET"
operations of collections. data. The collection is a data-structure that has these operations:
.addItem( data )
.resetNext() = start at the beginning
.hasNext() → tells whether there is another item
in the list
.getNext() → retrieves a data item from the
collection
.isEmpty() → check whether collection is empty
4.2.3 Discuss an algorithm to 3 Students should be expected to A binary search is faster - O( log N ),
solve a specific problem. discuss the differences between but can only be performed in a SORTED list
algorithms, including both standard A sequential search is slower - O(N)
and novel algorithms. For example, but can be performed whether the list is sorted or not
discussing the advantages and
disadvantages of using a binary A bubble sort can "quit early" if no swaps are made
search as opposed to a sequential in a pass. But it makes lots of swaps.
search. A selection sort must always perform N passes -
it cannot "quit early". But it makes fewer swaps -
maximum of N swaps
Both Bubble and Selection sorts are O(n^2)
4.2.4 Analyse an algorithm 3 Examination questions may involve Be sure to learn the correct shapes of boxes:
presented as a flow chart. variables, calculations, simple and
nested loops, simple conditionals Input/Output = parallelogram
and multiple or nested conditionals.
This would include tracing an Process(calculation) = rectangle
algorithm as well as assessing its
correctness. Decision (if..then) = diamond
Students will not be expected to
construct a flow chart to represent Start/end/connect = circle
an algorithm in an externally
assessed component.
MYP Mathematics: using flow
charts to solve problems in real-life
contexts, patterns and sequences,
logic, algorithms.
MYP Technology: design cycle
(inputs, processes, outputs,
feedback, iteration).
4.2.5 Analyse an algorithm 3 Examination questions may involve Practice here: Pseudocode Practice Tool
presented as pseudocode. variables, calculations, simple and
nested loops, simple conditionals Here are some old IB questions
and multiple or nested conditionals. presented with Pseudocode.
This would include tracing an Old Exam Questions
algorithm as well as assessing its These questions are REALLY OLD
correctness. and require some updating still.
MYP Mathematics: using flow
charts to solve problems in real-life
contexts, patterns and sequences,
logic, algorithms.
MYP Technology: design cycle
(inputs, processes, outputs,
feedback, iteration).
4.2.6 Construct pseudocode to 3 MYP Mathematics: using flow Practice here: Pseudocode Practice Tool
represent an algorithm. charts to solve problems in real-life
contexts, patterns and sequences,
logic, algorithms.
MYP Technology: design cycle
(inputs, processes, outputs,
feedback, iteration).
AIM 4 Demonstrate thinking skills
to represent a possible solution to a
specified complex problem.
4.2.7 Suggest suitable algorithms 3 Suitable algorithms may include For example:
to solve a specific problem. both standard algorithms and novel If PRICES and NAMES and INVENTORY are parallel arrays,
algorithms. Suitable may include write an algorithm that finds all the items where
considerations of efficiency, INVENTORY is below 10 items, and adds 20% to the
correctness, reliability and PRICES of those items.
flexibility. Students are expected to
suggest algorithms that will actually
solve the problem successfully.
LINK General principles of
computational thinking, introduction
to programming.
4.2.8 Deduce the efficiency of an 3 Students should understand and Big O notation is not required, but makes things simpler:
algorithm in the context of explain the difference in efficiency
its use. between a single loop, nested Sequential Search → O(n) (n is the length of
loops, a loop that ends when a the list)
condition is met or questions of
similar complexity.
Binary Search → O( log n ) (that's log base 2)
Students should also be able to
suggest changes in an algorithm
that would improve efficiency, for Bubble Sort → O( n^2 )
example, using a flag to stop a
search immediately when an item is [HL] Travelling Salesman Problem → O( n ! )
found, rather than continuing the
(n=number of cities)
search through the entire list.
4.2.9 Determine the number of 3 Examination questions will involve "number of steps" is called ITERATIONS
times a step in an algorithm specific algorithms (in
will be performed for given pseudocode/flow charts), and In nested loops, multiply the lengths of each loop
input data. students may be expected to give to determine iterations of inner-most command
an actual number (or range of
numbers) of iterations that a step
will execute.
4.3 introduction to programming (13 hours)
Assessment statement Ob Teacher’s notes Explanations and Examples
4.3.1 State the fundamental 1 These include: add, compare, ADD means numerical addition
operations of a computer. retrieve and store data.
Complex capabilities are This is referring to Machine Code - the language that
composed of very large numbers a CPU actually understands = NATIVE code
of very simple operations.
4.3.2 Distinguish between 2 For example, “find the largest” is a Add accumulator plus 1 → fundamental
fundamental and compound operation. Store accumulator into memory → fundamental
compound operations of a
Storing 1,3,5,7,...,99 → compound (uses a loop)
computer.
Comparing two Strings → compound, as it must loop
through
the Strings and compare many individual
characters
4.3.3 Explain the essential 3 For example, fixed vocabulary, English is not a computer language because meaning is
features of a computer unambiguous meaning, consistent NOT unambiguous - for example "store" has several
language. grammar and syntax. different meanings
TOK Language and meaning.
Example computer languages:
Java, Javascript, Python, Fortran, Basic, C++
4.3.4 Explain the need for higher 3 For example, as the human needs High Level code is easier to write, as one single command
level languages. for computer systems have like output ARRAY might print out 100 numbers,
expanded it is necessary to but low level languages require a loop for this task.
abstract from the basic operations
of the computer. It would take far High Level code may provide more sophisticated concepts,
too long to write the type of like Object Oriented Programming, that make programming
systems needed today in machine easier and quicker and more reliable
code.
High Level language tools often provide sophisticated and
automated error-checking, -prevention, and -handling
4.3.5 Outline the need for a 2 For example, compiler, interpreter, CPUs and Compilers and Virtual Machines
translation process from a virtual machine.
higher level language to Compiler - reads the entire program (source code) searching
machine executable code. for syntax errors. If no errors are found, it translates
the High Level source code into low level machine code,
that can run directly on the CPU.
4.3.6 Define the terms: variable, 1 variable = a name that represents a value
constant, operator, object. constant = a value that cannot change during run-time
operator = numerical operations, String operations,
logical (boolean) operations
e.g. operations on primitive data types
object = a collection of data and methods, created from
a design (class), allowing multiple INSTANCES
An object has a REFERENCE VARIABLE
that "points to" the contents of the object
4.3.7 Define the operators 1 LINK Approved notation sheet. div = integer division, no fractional part in the result
=, ≠, <, <=, >, >=, mod = the remainder from an integer division
The others are COMPARISON operators - they are also
mod, div.
BOOLEAN operators as they produce TRUE or FALSE results.
4.3.8 Analyse the use of 3 For example, identify and justify Local variable = created inside a method, with SCOPE
variables, constants and the use of a constant as opposed that extends only to that method - it is not available
operators in algorithms. to a variable in a given situation. outside that method
MYP Mathematics: forms of
numbers, algebra—patterns and Global variable = created outside all methods, and hence
sequences, logic, algorithms. usable (meaningful) in all the methods in the program
4.3.9 Construct algorithms using 3 Teachers must ensure algorithms Loops - in Pseudocode : loop C from 1 to 10
loops, branching. use the symbols from the approved ...
notation sheet. end loop
LINK Approved notation sheet.
MYP Mathematics: using flow loop while not FOUND do
charts to solve problems in real-life …
contexts, logic, algorithms end loop
MYP Technology: design cycle
(inputs, processes, outputs, Branching - in Pseucode : if … then
feedback, iteration). …
LINK Connecting computational else if … then
thinking and program design. …
else
...
Example:
NAMES.addItem("Bob")
NAMES.addItem("Dave")
NAMES.addItem("Betty")
NAMES.addItem("Kim")
NAMES.addItem("Debbie")
NAMES.addItem("Lucy")
NAMES.resetNext()
method firstLetter(s)
return s.substring(0,1)
end method
Output:
Dave
Debbie
4.3.11 Construct algorithms using 3 LINK Connecting computational See the examples in
the access methods of a thinking and program design. Pseudocode Practice Tool
collection.
4.3.12 Discuss the need for sub- 3 Show an understanding of the Too bad that IB Pseudocode contains no
programmes and usefulness of reusable code and facility for writing methods or sub-programs.
collections within program organization for the
programmed solutions. individual programmer, team
members and future maintenance.
LINK General principles of
computational thinking, connecting
computational thinking and
program design.
MYP Technology: use of software
such as Alice.
4.3.13 Construct algorithms using 3 MYP Mathematics: using flow See the examples in
pre-defined sub- charts to solve problems in real-life Pseudocode Practice Tool
programmes, one- contexts, logic, algorithms.
dimensional arrays and/or MYP Technology: design cycle
collections. (inputs, processes, outputs,
feedback, iteration); use of
software such as Alice.
Students will only be required to
analyse flow charts in the
externally assessed components.
Students will be expected to write
and analyse pseudocode in the
externally assessed components.
S/E, AIM 8 Appreciate the
implications of using available
code from sources such as online
forums.
LINK Connecting computational
thinking and program design.