Comp 2 - Computer Science Ko
Comp 2 - Computer Science Ko
Comp 2 - Computer Science Ko
1
2.1 – Algorithms - Computational Thinking
What is Computational thinking?
KEY TERMS
Algorithm: Steps to provide a solution
3
Flowcharts
to a problem, usually represented in
The thought processes involved in flowcharts or pseudocode
Displays an algorithm in diagram form using
formulating a problem and its symbols and arrows to show to flow of
Decompose: Breaking down a large information
solution(s), so that a computer,
problem into smaller sub-problems
human or machine can effectively Pseudocode
carry out Abstraction: Representing 'real world' A structured use of English used to define
problems in a computer using variables the steps needed to solve a problem.
1 and symbols and removing unnecessary
elements from the problem
INPUT/OUTPUT
PROCESS
5
2.1 – Sorting Algorithms – Bubble, Insertion & merge
6
2.2 Programming Techniques Syntax Error
Constant An error in the rules/grammar of the language Eg missing colon / spelling mistake
Value STORED IN A MEMORY LOCATION that
never changes WITHIN A PROGRAM Logic Error
The program is written to do something other than what the programmer intended
Variable Eg Resetting only the first 9 elements in an array instead of all 10.
Value STORED IN MEMORY LOCATION that
Run Time Error:
can change WITHIN IN A PROGRAM More difficult to spot as it can run a program without reporting an error. E.g. runs but
Doesn’t give an output. Or the program hangs or Becomes inactive
TUPLE IMMUTABLE ()
DIFFERENT DATA TYPES E.G. (1,2, “Hello”, 4.3)
ARRAY IMMUTABLE []
SAME DATA TYPE E.G [1,2,3,4] 8
2.3 Robust Programs Data Validation techniques
Maintainability : Updating code so that it is compatible Anticipating Misuse: Defensive program design will consider and anticipate
with current requirements misuse. Misuse may be in the form of a brute force attack on the program.
E.G Many programs and systems only allow a user to enter a password three
Comments: To help describe the code and structures or four times before it locks out the system.
in a program using #
Contingency Planning: Once a programmer has anticipated the misuse they can
Indentation: used to show the programs structure e.g. then plan for the these issues. For example: Limiting the number of logon
where selection or iteration or functions are used . attempts. Ensuring the code is robust in validating the data entered
9
2.3 Robust Programs Test data – When testing your programs it is important to use of
data to test and to create a test plan.
Iterative testing: This happens overtime and is repeated
throughout the development of the program
10
2.4 Computational logic Truth Tables: Display all possible
outcomes for that gate
Logic Gate: A building block of a digital circuit. They
perform logical functions in a circuit and use binary
IN OUT
Not Gate 0 1
Inverts the input (0 becomes 1 and 1 1 0
becomes 0
A B Out
OR Gate 0 0 0
0 1 1
Wait for either inputs to be 1 for output to
be 1 1 0 1
A OR B 1 1 1
A B Out
AND Gate
0 0 0
Both inputs to be 1 for output to be 1 0 1 0
A AND B
1 0 0
11
1 1 1
TRANSISTOR: A tiny switch that is activated by the
2.4 Computational logic electronic signals it receives. The digits 1 and 0
used in binary reflect the on and off states of this.
Code Editor – edits program text, you can type our your source Executable Code: Files which contain
code here instructions in machine code. These
Syntax Checks – Highlights syntax errors instructions are carried out in the computer
hardware
Runtime Environment – allows programs to be run one line at a
time – helps test programs and locate errors. Programming Standards
Code should follow agreed conventions (EG Lowercase for
Translator – Compiles or interprets the code variable names, schemes to be followed).
Language code is written in.
Libraries – Provides functions not included in core part of Functions used to tidy up repeated code.
programming languages (eg Random)
Comments explain the code clearly.
Correct use of indentation.
Debugger – Helps to detect errors. Suggests what type of error it
is and what line it is on. Useful identifiers (File names & Variable names)
Code should follow agreed conventions 15