higher cs standard algorithms part 2- techniques to help with learning about standard algorithms

26
HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Upload: brayden-young

Post on 01-Apr-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

HIGHER CS STANDARD ALGORITHMSPart 2- Techniques to help with learning about standard algorithms

Page 2: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Session Overview

• Visualising hidden mechanisms- Limitations of visualisation only- Weaknesses of existing methods for visualising

hidden mechanisms- Introduction to the mechanism visualiser

Page 3: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Visualising the hidden mechanisms

Is showing them in action enough?

Getting students to create a visualisation instead• Current methods and their limitations• Introduction to the mechanism visualiser

- Short demonstration- Tracing through a small linear search

Page 4: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Is showing them in action enough?

• Pupils need to build a causal model

• Watching a process helps but it’s not enough

• Too much work for the eyes and not enough work for the brain

Page 5: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

What current methods do you use?

• Drawing a flowchart from a piece of code

• Drawing a structure diagram from a piece of code

• Tracing through a piece of code with a trace table

• Asking pupils to predict what will happen next

• Getting pupils to evaluate expressions

Page 6: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Limitations

Flow of Control

• Flowcharts• Predict

what happens next

Data Flow

• Expressions

• Trace Tables

Block Structure

• Structure Diagram

All of them develop understanding of part of the mechanismsSome involve having to learn another notation

Page 7: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

MECHANISM VISUALISER EXAMPLE

Page 8: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Variables Table

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 1- Draw a red rectangle around all expressions

Expression evaluator

Page 9: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 1- Draw a rectangle around all expressions Variables Table

Expression evaluator

Page 10: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Variables Table

Expression evaluator

Step 2- Draw in the flow of control as arrows

Page 11: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 2- Draw in the flow of control as arrows

T

F

Variables Table

Expression evaluator

Page 12: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 3- Hand execute the program with inputs 20, 7, -1

T

F

Variables Table

Expression evaluator

Page 13: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Total

1. 0

Variables Table

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 3- Hand execute the program with inputs 20, 7, -1

T

F

1

Expression evaluator

Page 14: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Total nextInput

1. 0 2. 20

Variables Table

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 3- Hand execute the program with inputs 20, 7, -1

T

F

1.

2.

Expression evaluator

Page 15: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Total nextInput

1. 0 2. 20

Variables Table

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 3- Hand execute the program with inputs 20, 7, -1

T

F

1.

2.

3.3. nextInput !- -1

20 != -1True

Expression evaluator

(3)

Page 16: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Total nextInput

1. 0 2. 20

4. 20

3. nextInput !- -120 != -1True

4. total + nextInput0 + 2020

Variables Table

Expression evaluator

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 3- Hand execute the program with inputs 20, 7, -1

T

F

1.

2.

3.

4.

(3)(4)

Page 17: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Total nextInput

1. 0 2. 20

4. 20 5. 7

3. nextInput !- -120 != -1True

4. total + nextInput0 + 2020

Variables Table

Expression evaluator

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 3- Hand execute the program with inputs 20, 7, -1

T

F

1.

2.

3.

4.

5.

(3)(4) (4)

Page 18: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Total nextInput

1. 0 2. 20

4. 20 5. 7

3. nextInput !- -120 != -1True

4. total + nextInput0 + 2020

6. nextInput != -17 != -1True

Variables Table

Expression evaluator

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 3- Hand execute the program with inputs 20, 7, -1

T

F

1.

2.

3.

4.

5.

6.

(3)(4)

(6)

(4)

Page 19: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

Total nextInput

1. 0 2. 20

4. 20 5. 7

7. 27

3. nextInput !- -120 != -1True

4. total + nextInput0 + 2020

6. nextInput != -17 != -1True

7. total + nextInput20 + 727

Variables Table

Expression evaluator

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 3- Hand execute the program with inputs 20, 7, -1

T

F

1.

2.

3.

4. 7.

5.

6.

(3)(4)

(6)(7)

(4)

(7)

Page 20: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

total nextInput

1. 0 2. 20

4. 20 5. 7

7. 27 8. -1

3. nextInput !- -120 != -1True

4. total + nextInput0 + 2020

6. nextInput != -17 != -1True

7. total + nextInput20 + 727

Variables Table

Expression evaluator

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 3- Hand execute the program with inputs 20, 7, -1

T

F

1.

2.

3.

4. 7.

5. 8.

6.

(3)(4)

(6)(7)

(4)

(7)

Page 21: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

total nextInput

1. 0 2. 20

4. 20 5. 7

7. 27 8. -1

3. nextInput !- -120 != -1True

4. total + nextInput0 + 2020

6. nextInput != -17 != -1True

7. total + nextInput20 + 727

9. nextInput != -1-1 != -1False

Variables Table

Expression evaluator

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 3- Hand execute the program with inputs 20, 7, -1

T

F

1.

2.

3.

4. 7.

5. 8.

6. 9.

(3)(4)

(6)(7)

(4)

(7)

(9)

Page 22: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

total nextInput

1. 0 2. 20

4. 20 5. 7

7. 27 8. -1

3. nextInput !- -120 != -1True

4. total + nextInput0 + 2020

6. nextInput != -17 != -1True

7. total + nextInput20 + 727

9. nextInput != -1-1 != -1False

Variables Table

Expression evaluator

SET total TO 0

RECEIVE nextInput FROM (INTEGER) KEYBOARD

WHILE nextInput != -1 DO

SET total TO total + nextInput

RECEIVE nextInput FROM (INTEGER) KEYBOARD

END WHILE

SEND total TO DISPLAY

Step 3- Hand execute the program with inputs 20, 7, -1

T

F

1.

2.

3.

4. 7.

5. 8.

6. 9.

(3)(4)

(6)(7)

(4)

(7)

(9)

10.

Page 23: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

In Pairs• Identify all of the expressions by

drawing a box around them• Identify the control flow by drawing

arrows showing what the next instruction will be

• Hand execute the program making sure to evaluate complicated expressions and create and update variables

Page 24: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

SET found TO FALSE

SET numList TO [8,9,13,4]

RECEIVE searchKey FROM (INTEGER) KEYBOARD

SET pos TO 0

WHILE found TRUE AND pos < length (numList) DO

IF numList [ pos ] = searchKey THEN

SET found TO TRUE

ELSE

SET pos TO pos + 1

END IF

END WHILE

Array

Variables Table

Expression evaluator

Hand execute program with 13 as input for searchKey

Page 25: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

SET found TO FALSE

SET numList TO [8,9,13,4]

RECEIVE searchKey FROM (INTEGER) KEYBOARD

SET pos TO 0

WHILE found TRUE AND pos < length (numList) DO

IF numList [ pos ] = searchKey THEN

SET found TO TRUE

ELSE

SET pos TO pos + 1

END IF

END WHILE

Step 1 and 2 Complete

FT

FT

Array

Variables Table

Expression evaluator

Page 26: HIGHER CS STANDARD ALGORITHMS Part 2- Techniques to help with learning about standard algorithms

F

T 13.

T

found searchKey pos

1.FALSE (5) 3. 13 (6)(9)(12) 4. 0 (5) (6)

13.TRUE (14)

Array 2. numList

[0] [1] [2] [3]

8 (6) 9 (9) 13 (12) 4

Variables Table

SET found TO FALSE

SET numList TO [8,9,13,4]

RECEIVE searchKey FROM (INTEGER) KEYBOARD

SET pos TO 0

WHILE found TRUE AND pos < length (numList) DO

IF numList [ pos ] = searchKey THEN

SET found TO TRUE

ELSE

SET pos TO pos + 1

END IF

END WHILE

6 numList[ pos ] = searchKeynumList[ 0 ] = 138 = 13False

9 numList[ pos ] = searchKeynumList[ 1 ] = 139 = 13False

12 numList[ pos ] = searchKeynumList[ 2 ] = 1313 = 13True

Expression evaluator

Step 3 Complete-

F

Hand execute program with 13 as input for searchKey

1.

2.

3.

4.

5.

6. 9. 12.

7. 10..

8.11.14..

15.