[go: up one dir, main page]

100% found this document useful (1 vote)
92 views7 pages

Edexcel IGCSE Computer Science

The document provides an overview of algorithms, detailing their characteristics such as accuracy, consistency, and efficiency. It explains different formats for representing algorithms, including flowcharts and pseudocode, and discusses control structures like sequences, selections, and loops. Additionally, it covers basic programming concepts such as variables, constants, and logical operators.
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
100% found this document useful (1 vote)
92 views7 pages

Edexcel IGCSE Computer Science

The document provides an overview of algorithms, detailing their characteristics such as accuracy, consistency, and efficiency. It explains different formats for representing algorithms, including flowcharts and pseudocode, and discusses control structures like sequences, selections, and loops. Additionally, it covers basic programming concepts such as variables, constants, and logical operators.
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/ 7

Edexcel IGCSE Computer Science

Problem Solving
Understanding Algorithms
What is an algorithm?
o An algorithm is a sequence of steps that can be followed in all order to complete a task.

What are the characteristics of an algorithm?


o Accuracy- it must lead to the expected outcome.
o Consistency- it must produce the same result each time it is run.
o Efficiency- it must solve the problem in the shortest possible time, using a few computer
resources.

What is a written description?


o A written description is the simplest way of expressing an algorithm.

Example:
o Produce a written description of an algorithm for borrowing a book from the library.
o Enter the library
o Choose a book you would like to read.
o Check if you have read it before.
o Record your details.
o Walk out of the library with the book.

Algorithms
o Algorithms are divided into 2 different formats.
o Flowchart- graphical representation
o Pseudocode- Structured format
Flowcharts
o Flowcharts can be used to show an algorithm as a diagram. It’s a graphical
representation of an algorithm.

Example:
o Produce a flowchart describing an algorithm for borrowing an book from the library.

Start

Enter the library

Choose the book you would like to read

Check if you have read it before

Record your details

Walk out of the library with the book

End
Controlled Structures
What are the three types of control structures used in an algorithm?
o Sequence- If the steps from the beginning to the end of an algorithm are carried out in a
strict order.
o Selections- A construct that allows a choice to be made between different alternatives.
o E.g.: - Simple IF, IF < > THEN ELSE ENDIF, NESTEDIF, CASE < > OF
o Repetitions/ loops- If one or several steps of an algorithm are repeated until a condition
is satisfied.
o E.g.: - REPEAT, FOR NEXT, WHILE DO

Pseudocode keywords
Input SEND “Enter Number 1” TO DISPLAY
RECEIVE Number1 FROM KEYBORD
Process SET total TO 0
SET total TO Number1+Number2
Output SEND “The total is”, total TO DISPLAY

Example:
o Write a pseudocode to find perimeter and area of a rectangle.
Answer:
SEND “Enter length” TO DISPLAY
RECEIVE length FROM KEYBOARD
SEND “Enter width” TO DISPLAY
RECEIVE width FROM KEYBOARD
SET Area TO length * width
SET Perimeter TO (width+length)*2
SEND “The Area is” & Area TO DISPLAY
SEND “The Perimeter is” & Perimeter TO DISPLAY
Arithmetical Operations
Function Operator
Addition +
Subtraction -
Multiplication *
Real division /
Quotient // / DIV
Modulus/modulo % / MOD
Exponentiation ** / ^

What is a variable?
o The data stored in a variable is referred to as a value. The value stored in a variable is not
fixed. The same variable can store different values during the course of a program and
each time a program is run.

What is a constant?
o A container that holds a value that never changes: like variables, constants have unique
identifiers.

Selections
What is a selection?
o A construct that allows a choice to be made between different alternatives.
Simple IF condition

Is
expression
?
IF …. THEN …. ELSE …. ENDIF
IF <expression>THEN
<command>
ELSE
<command>
ENDIF

NESTED ‘IF’
IF <expression> THEN
<command>
ELSE
IF <expression> THEN
<command>
ELSE
<command>
ENDIF
ENDIF

Logical Operators
‘AND’ operator
o If two conditions are joined by the ‘AND’ operator, then they must both be true for the
whole statement to be true.

‘OR’ operator
o If two conditions are joined by the ‘OR’ operator, then either one must be true for the
whole statement to be true.
Loops
o Loops are used to make a computer repeat a set of instructions more than once.
o Definite- when the number of repetitions of loops is known in advance
o FOR loop
FOR <id> FROM <expression> TO <expression> DO
<command>
ENDFOR
o Repeat loop
o Indefinite
o While loop
o Repeat until

You might also like