4.2 – Connecting computational thinking and program design

4.2.1 – Describe the characteristics of standard algorithms on linear arrays

Variable

A variable is a storage location that can be used to store a value

The name of the variable is known as the identifier

Array

An array can hold multiple data elements of the the same type.

It also has a name and a size that can not be changed during execution hence its type static structure.

Sequential Search /Linear Search

Sequential Search /Linear Search- pseudocode

Binary Search

Binary Search – Pseudocode

Bubble Sort

Probably the weirdest thing I have seen in regards to a bubble sort!

Bubble Sort in Pseudocode

Selection Sort

Software

This is a great piece of software (click image) to become more comfortable with the above.

4.2.2 – Outline the standard operations of collections

As far as the IB is concerned collections are:

Collections store a set of elements. The elements may be of any type (numbers, objects, arrays, Strings, etc.).

Collections can be also Un-ordered and of Unknown length

Typical Methods for collections are the listed below

4.2.3 – Discuss an algorithm to solve a specific problem

This from the Teachers Notes section of the IB syllabus

Students should be expected to discuss the differences between algorithms, including both standard and novel algorithms. For example, discussing the advantages and disadvantages of using a binary search as opposed to a sequential search.

The advantages and disadvantages of such novel algorithms are detailed in 4.2.1

4.2.4 – Analyse an algorithm presented as a flow chart.

This from the Teachers Notes section of the IB syllabus

Examination questions may involve variables, calculations, simple and nested loops, simple conditionals and multiple or nested conditionals. This would include tracing an algorithm as well as assessing its correctness. Students will not be expected to construct a flow chart to represent an algorithm in an externally assessed component.

This basically involves being able to understand flow chart symbols
Basic flowchart symbols
How flow charts operate
flowchart templates of Banking teller

4.2.5 – Analyse an algorithm presented as pseudo code.

Examination questions may involve variables, calculations, simple and nested loops, simple conditionals and multiple or nested conditionals. This would include tracing an algorithm as well as assessing its correctness.

4.2.6 – Construct pseudo code to represent an algorithm.

This is all about practice!.

Do not always rely on IDE’s like IntelliJ and IDLE to write code.

You need to be able to write algorithm solutions on paper and be able to trace through them to solve problems.

4.2.7 – Suggest suitable algorithms to solve a specific problem

Again this is just practice.

Come up with a particular problem between a group of you. Each of you write code to solve this problem independently and then look at each other solutions .

Remember there are lots of different ways to solve them same problem but it may be good to see other peoples way of thinking.

5 brains are far better than 1

4.2.8 – Deduce the efficiency of an algorithm in the context of its use

Again this comes down to practice and testing.

Think for a very simple solution of drawing a square

Image result for square

We could do this:

  • draw a 10cm line
  • turn 90 degrees
  • draw a 10cm line
  • turn 90 degrees
  • draw a 10cm line
  • turn 90 degrees
  • draw a 10cm line
  • turn 90 degrees

OR

We could do this:

Repeat 4 times

  • draw a 10cm line
  • turn 90 degrees

If you think a loop that repeats 10 times will take 10 times to run

Now if you have another nested loop inside of the first loop that also repeats 10 times it now takes 100 times to run.

It may be that the code would be more efficient using a boolean while loop that terminates when the condition is met

4.2.9 – Determine the number of times a step in an algorithm will be performed for given input data

This is about tracing the algorithm or the section of the algorithm to see what it is actually doing

You can see in the next screenshot that the loop will run as many times as there are items in the DATA collection (In this case it is 4)

This next code will execute N x N times: