Paper 1 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is an algorithm?

A

A sequence of steps that can be followed to complete a task.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a computer program?

A

An implementation (application) of an algorithm.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is decomposition?

A

The process of breaking down a complex problem into sub-problems or more manageable chunks, so each sub-problem accomplishes an identifiable task.
* This makes the problem easier to understand.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is abstraction?

A

Abstraction is the process of removing unnecessary detail from a problem.
* This SIMPLIFIES the problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What makes an algorithm efficient?

A
  • Takes less time to execute.
  • Less calculations are required for the algorithm to be completed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does the linear search algorithm work?

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Why is it important to use a meaningful identifier name?

A
  • Describes the role of the variable
  • Making the algorithm easier to understand
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are the advantages of using the structured approach/ subroutines?

A
  • Subroutines can be developed seperately
  • It is easier to discover errors
  • Subroutines can be updated without affecting the overall program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What should the conditions of an algorithm be?

A
  • Preicse
  • Well-defined
  • Finite
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is pseudocode?

A
  • Informal description
  • Intended for human reading and understanding, but understands code
  • No standardised (correct) syntax
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Flowcharts:

A
  • Symol for start/end of an algorithm- ⬭
  • Symbol for a process being carried out- ☐
  • Symbol for a decision to be made- ⬦
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

The linear search algorithm:

A
  • Works by checking each element to see if it matches the target
  • This repeats until a match has been found or the whole list of values has been checked
  • WHEN PROGRAMMING THIS USE A BOOLEAN VALUE TO KEEP TRACK OF THE VALUE AND IF IT HAS BEEN FOUND/NOT FOUND.
    🚩- Not efficient for long lists
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

The binary search algorithm:

A
  • List must be ordered first to work- extra step. If this is not done, the program is inefficient and won’t work.
  • OVERALL, BINARY SEARH IS MORE EFFICIENT THAN LINEAR SEARCH.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Compare the bubble sort and merge sort algorithm.

A
  • Bubble sort is less efficient than merge sort
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a variable?

A
  • An address in memory
  • That is given a name
  • That is assigned a value
  • That can change whilst the program is running.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Define constant.

A
  • An address in memory
  • That is given a name
  • That is asigned a value
  • That cannot change while the program is running
17
Q

Advantages of using a constant:

A

1) You only have to change the value of the constant once in the source code. If we didn’t have the constant we’d have to hunt through the program to find all the places where we’d written 4 and change them to the new number.
2) It makes sure that our program is consistent as we only have to enter the value once.
3) If lots of people are working on the same program it stops mistakes happening.
4) It also makes your code more readable. For example if you are writing a program to calculate with circles it is much easier to have a constant called PI than to have to keep typing 3.1415…

18
Q

How do you identify a constant?

A

A constant has an ALL UPERCASE VARIABLE name.

19
Q

What are the three main constructs?

A
  • Sequence - the idea of one step being done after another in a particular order
  • Iteration - repeating sections of code in a loop (FOR, WHILE, REPEAT)
  • Selection - changing the direction of a program based on a specific criteria (IF, SELECT CASE)
20
Q

Iteration- indefinite loop (condition controlled loop):

A
  • Condition controlled loops are the that in which the end of the loop is unknown, it will continue indefinetely until the condition is met.
21
Q

Which condition controlled loop is adavntageous and why?

A

The REPEAT…UNTIL loop
* Th same effect is achieved with both WHILE…ENDWHILE and REPEAT…UNTIL loop
* But the REPEAT…UNTIL loop allows the program to enter the loop, gain an input, then test the condition at the end
* The WHILE…ENDWILE loop will keep running UNTIL the the conditio is met, but the REPEAT…UNNTIL loop only runs when the condition is met.
* This makes it more efficient.

22
Q

What are the two types of indefinite loop?

A
  • Pre-controlled loops – the condition is checked before the loop starts, and will keep going whilst the condition is TRUE. E.g. END…ENDWILE
  • Post-controlled loops – the condition is checked once the loop has finished, and will stop as soon as the condition is TRUE. E.g. REPEAT…UNTIL
23
Q

What is an exaple of a pre-controlled loop.

A

WHILE count < 5
count ← count + 1
ENDWHILE

24
Q

What is an example of a post-controlled loop.

A

REPEAT
count ← count + 1
UNTIL count < 5

25
Q

What is a definite loop (count-controlled loop)?

A
  • A loop that has a definite amount of times to run
  • If you do know how many times the loop will repeat, you use a definite loop.
26
Q

Example of a definite loop.

A

FOR count ← 1 TO 5
OUTPUT count
ENDFOR

This loop will run 5 times. Each time through the loop, count will increase by 1 until it reaches 5.

27
Q

What is nesting?

A

When a statement is put inside of another.

28
Q

Give an example of nested selection.

A

WHILE abc
FOR xyz
ENDFOR
ENDWHILE

29
Q

What is the rule for integer and string concatenation?

A

Python doesn’t allow adding/ concatenating an integer (i) and a string directly. In Python, you need to convert the integer to a string before concatenating it with another string.

for i in range (1,10):
print (str(i + “times table”))
for j in range (1,12):

30
Q

Give an examle of nested selection.

A

IF abc
IF aabc
ENDIF
ENDIF

31
Q

Define selection.

A

The ability too change the flow of the program, based on a condition thats is met.

Examples:
* If, else

32
Q

What are the 2 types of division?

A
  • Integer division- // in python, DIV in pseudocode. This cuts off any number after integer, so all decimal values will be ignored.
  • Real/float division- /
33
Q

Boolean operators:

A
  • NOT- This reverses the input (NOT TRUE = FALSE)
  • AND- This checks if both inputs are TRUE and returns TRUE __if so, __FALSE otherwise
  • OR- This checks if either input is TRUE and returns TRUE if so, __FALSE __otherwise
34
Q

Pseudocode vs flowcharts:

A
  • In general, pseudocode is much easier to create accurate and detailed algorithms. In flowcharts it is too easy to miss out a step, or combine the hard bits together into one block.
  • However, flowcharts are a much easier way to see the flow of a program and how it runs from start to finish.
  • You are able to use both in your exam, although it is recommended that you use pseudocode, as you are less likely to drop silly marks
35
Q

What is a relational operator?

A

Used to compare the relationship between two variables/values
* E.g. > or !=

36
Q

What is an arithemtic operator?

A

Used to perform a mathematical function between 2 variables/values.
* E.g. +, -, *, /, //

37
Q

Define array.

A

An array is defined as multiple spaces in memory, under a single indetifier, in order to group elements together.

38
Q

Give an example of a one dimensional array.

A

primes ← [ 2, 3, 5, 7, 11, 13 ]

39
Q
A