2.1 Algorithms Flashcards Preview

GSCE Computer Science OCR > 2.1 Algorithms > Flashcards

Flashcards in 2.1 Algorithms Deck (48)
Loading flashcards...
1
Q

What is Abstraction?

A

Process of removing unnecessary details and including only the relevant details

2
Q

What is Decomposition?

A

Breaking a complex problem into smaller more manageable parts

3
Q

What is Algorithmic Thinking?

A

Creating a step by step solution to a problem

4
Q

What are the 2 types of searching algorithms?

A

Binary and Linear search

5
Q

What are the advantages of a Linear Search?

A

Simple
The list doesn’t need to be ordered
Easy to program

6
Q

What are the disadvantages of a Linear Search?

A

Not efficient

Takes time with a lot of data

7
Q

What are the advantages of a Binary Search?

A

More efficient than a linear search

8
Q

What are the disadvantages of a Binary Search?

A

Only works on an ordered list

9
Q

How does linear search work?

A

Checks each item in the list one by one until it finds what it is looking for

10
Q

How does binary search work?

A
Finds the middle item in an ordered list
By doing n+1/2
Compares the item to the middle item
So it knows where to look in the first half of the second half
Repeats until the item is found
11
Q

What is a sorting algorithm?

A

Sorts items into an ordered list

12
Q

How does a bubble sort work?

A
Checks the first 2 items in a list
Swaps them if they are in the wrong order
Moves to the next items and Repeats
Moves through the entire list again
Until ordered
13
Q

How does a merge sort work?

A
Finds the middle item by (n+1)/2
Splits the list in half
Repeats until items are paired
Each time the sub-list are paired 
They are sorted into the correct order
14
Q

How does an insertion sort work?

A

Looks at 2nd item in the list and compares it to the items that are in front of it
Then inserts it into the right place correctly
It is Quick for sorting small lists

15
Q

What is the shape of the input box?

A

Parallegoram

16
Q

What is the shape of a decision making?

A

Diamond

17
Q

What is the shape of the process?

A

Rectangle

18
Q

What does the lines show?

A

The control passing betweens the connected shapes

19
Q

How do you output an statement?

A

Print(“hello”)

20
Q

How do you do a for loop in OCR Reference language

A

For i = 0 to 7

next i

21
Q

What are the comparison operators?

A
== Equal to
!= Not equal to
< Less than
<= Less than or equal to
> Greater than
>= Greater than or equal to
22
Q

What does 12 MOD 5 give?

A

2 - Because the MOD function always returns the remainder

23
Q

What does 12 DIV 5 give?

A

2 - DIV functions returns how much a number goes into another number - excluding remainders

24
Q

How do you do an IF - THEN - ELSE in OCR Exam Reference Language?

A
If x== 6 then
...
elsif .. then
..
else
...
endif
25
Q

How do you do an CASE SELECT or SWITCH?

A
Switch x:
  case "a":
   ....
  case "b":
  ...
  default: (Same as an else equivalent)
endswitch
26
Q

How do you get a length of a spring?

A

Variable.length

27
Q

How do you get “put” from subject = “ Computer Science”

A

subject.substring(3,3))

will start at position p - because the string starts at the 0th character

then count the character its on and go 2 along

which will print out put

28
Q

How do you make a string in all upper cases?

A

String.upper

29
Q

How do you make a string in all lower cases?

A

string.lower

30
Q

What is an example of a procedure?

A

procedure name(..)

endprocedure

31
Q

What is an example of a function?

A
function name(..)
  ...
  return ...
  endfunction
32
Q

How do you call a function?

A

function(parameters)

33
Q

How do you call a procedure?

A

procedure(parameters)

34
Q

How do you establish an array?

A

array name[5] - example

array name[number of boxes]

35
Q

How do you declare a 2D array?

A

For example

array board[8,8]

36
Q

How do you make a random number?

A

myVariable = random(1,6)

37
Q

How do you open a file?

A

For example:

myFile = open(“sample.txt)

38
Q

How do you close a file?

A

myFile.close()

39
Q

How do you read/write a file?

A

Myfile.readLine( )

Myfile.writeLine(..)

40
Q

How do you end a file/ create a file?

A

myFile.endOfFile()

newFile()

41
Q

What are syntax errors?

A

Errors which break the grammatical rules of the programming language

Stop it from being run

42
Q

What are logic errors?

A

Errors that produce an unexpected output

On their own they won’t stop a program from running

43
Q

What are the advantages of constants?

A

Can make a program easier to read
Compiler can optimises the code
Less chance of errors

44
Q

What is a sequence?

A

Executing instructions one after another

45
Q

What is selection?

A

Program branching depending on the condition

46
Q

What is iteration?

A

Looping - repeating sections of the code

47
Q

When are FOR loops used?

A

Number of iterations needed is known ahead of the iteration executing

48
Q

When are WHILE loops used?

A

When the number of iterations is not known