0% found this document useful (0 votes)
35 views40 pages

FC Topic 1 - Computational Thinking

Uploaded by

Nour's Adventure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views40 pages

FC Topic 1 - Computational Thinking

Uploaded by

Nour's Adventure
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 40

Topic 1 - Computational

Thinking
SLR7 - Basic programming techniques
SLR8 - Advanced programming techniques
SLR10 - Algorithm and Logic
Decomposition and Abstraction
Decompositions - breaking down larger problems into smaller
subproblems, so they can be easier to solve.

Abstraction - Removing unnecessary information, leaving only the


necessary information required to solve the problem.
Exam Questions
1) Define decomposition

2) Define abstraction

You might be given a scenario, where you have to use abstraction. Identify for
the examiner the necessary information you need to solve the problem and what
information is unnecessary. (possible 6 marks)
Subprogram - Function and Procedures
Subprogram - Carries out a specific task within a larger program.

Benefits of subprogram
1) Improving the readability of code (make it easier to read and understand)
2) Making it easier to test/debug
3) Once written you can reuse the same code many times
4) Easier to work on in teams. (each person work on specific subprogram)
5) Makes the logic clearer.
6) Reducing the time needed to develop a solution,
Exam Questions
1) What is a subprogram?

2) Name 4 benefits of subprograms


Flow charts - Understand/Interpret a flowchart

Every flowchart need a start symbol, but not


always a stop, (if it loops forever)

In Python this means you either use the


keyword Input or Print

This symbols sets a variable or performs a


calculation.

This symbols means an If statement, or


if an arrow loops back to this symbol, it
means use a while loop
Subroutine Subprogram
Function or Procedure
Flowchart with a subroutine
Exam Questions
Paper 2 programming - You may get a Python question where you have to
translate a flowchart into a Python program.

Paper 1 theory - The examiner may give you a flow chart and ask you to interpret
it. For example give you some input and ask you what will be the output.
Pseudocode
An informal written description of a solution that uses imprecise English language
statements. Use for planning and developing your programs

e.g.

If password incorrect

Output that the password is wrong

Otherwise

Output the password is correct


Exam Questions
Exam Questions

You will be given some


code/pseudocode
1) The examiner will ask
you to identify parts of
the code.

2) The examiner will give


you some input and ask
you identify the outputs.
Variable and Constants
Variable - A value stored in memory that can change while the program is running.

Constant - A value that does not change while the program is running and is assigned when the
program is designed.

Identifier - The name you give to a variable or constant


Assignment - How do you give a variable or constant a value.
Using this symbol: =
Example: name = “Ahmed”
PI = 3.14
Exam Questions

Q1) What is the difference between a variable and a constant

Q2) State the assignment operator


Structure Data Types
List - You can store multiple item in a list, THEY DO NOT (HETEROGENEOUS) have to be of the same data type

Array - An array is similar to a list, but items THEY DO (HOMOGENEOUS) have to be of the same data type

Record - You can store multiple item in a list, THEY DO NOT (HETEROGENEOUS) have to be of the same data type
Exam Questions

Q1) Identify a data structure holds data of the same type?

Q2) Identify a data structure that allows data of different types to be stored?
Operators you must know
Exam Questions
Must understand BIDMAS rules

Brackets,
Indices,
Division,
Multiplication,
Addition,
Subtraction
Trace Tables

Used to run through a an algorithm one step at a time


1) To find errors
2) To understand an algorithm

num1 num2 total


Exam Questions
Programming Errors
● Syntax - break the grammatical rules of the languages
Stop the program from being run

● Logic - Produces an unexpected output


Will not stop the program from being run

● Runtime - Produces an error during runtime, due to missing file (cannot read
or write to a file)
Or illegal calculation (dividing by zero)
Causes program to crash while runing
Exam Questions

Q1) Describe what a runtime error is

Q2) What is the difference between a syntax and logic error.


Linear search - You must be able to code a linear search
Binary Search vs Linear Search
Binary Search - 66

3 4 8 10 34 55 66

34 55 66

66
3/2 = 2
Linear Search - 66

3 4 8 10 34 55 66
Exam Questions

Q1) In a binary search, what condition must be meet before it can be carried out?

Q3) Describe how a linear search works (4 marks)

Q2) Explain which searching algorithm is more efficient, linear or binary


Bubble Sort vs Merge Sort
Merge Sort
Step 1 - break list into separate individual lists

60 5 25 55 1 10

Step 2 - Merge the lists back together

5 25 55 60 1 10
Merge Sort

25 55 60

1 5 10 25 55 60
Merge Sort

Step 1 - Merge the lists back together

25 55 60

1 5 10 25 55 60
Exam Questions

Explain how a bubble sort


algorithm works (6 marks)
Bubble Sort Example
First Pass
A=1
Mahtab Mahtab Mahtab Adam Adam B=2
C=3
Adam Adam Adam Mahtab Fahd
D=4
Hamza Fahd Fahd Fahd Hamza E=5
Mathbab
F=6
Fahd Hamza Hamza Hamza
G=7
Taha Taha Taha Taha Taha H=8
I=9
J
K
L
Bubble Sort Example

First Pass A=1


Second Pass
Adam Adam B=2
Adam Adam Adam Adam C=3
Fahd Fahd
Mahtab
D=4
Mahtab Mahtab Fahd
Mahtab Hamza E=5
Fahd Fahd Fahd Mahtab F=6
Hamza Mathbab
Hamza G=7
Hamza Hamza Hamza
Taha Taha H=8
Taha Taha Taha Taha I=9
J
K
L
Bubble Sort Example
First Pass
5
5 5
10
60 10
20
50 60
50
10 50
60
20 20
Logic Gates - Truth Tables
AND

A B X A B X

0 0 0 0 0 0 0 0

1 0 1 0 1 0 1 1

2 1 0 0 2 1 0 1

3 1 1 1 3 1 1 1
S M S AND M

0 0 0

0 1 0

1 0 0

1 1 1
Exam Questions
Complete the truth table for this circuit

You might also like