Component 2- Algorithms Flashcards

1
Q

What is an algorithm?

A

A series of instructions that solves a problem in a finite number of steps

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

What three criteria lead to a successful algorithm?

A
  • Accuracy
  • Consistency
  • Efficiency
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a sequence?

A

An ordered set of steps or instructions

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

What does unambiguous mean?

A

Written in a way that makes it completely clear what is meant

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

What are the two ways to plan and design an algorithm?

A
  • Visual (Using flow chart symbols)
  • Text (Using a written sequence of instructions)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between an algorithm and a problem?

A

Before you can write a program to solve a problem, you have to work out the algorithm first

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

What is a variable?

A

A storage location used to store a value; this could be text or a number. The value stored in the variable may change as the program is run.

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

What are the rules for a variable name?

A
  • Must be written before a value is assigned to it
  • Cannot start with a number
  • Must not have spaces
  • Must make sense in algorithm
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is ‘=’ in OCR pseudocode?

A

Assignment of a value to a variable

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

What is ‘==’ in OCR pseudocode?

A

Shows equality

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

What is the flow chart symbol for a terminator and what does it show?

A
  • Oval / Rounded Rectangle
  • Start or end of algorithm
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the flow chart symbol for a process and what does it show?

A
  • Rectangle
  • Process in algorithm e.g. Calculating price
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the flow chart symbol for a decision and what does it show?

A
  • Diamond
  • Have one of two answers; yes or no, true or false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the flow chart symbol for an input or output and what does it show?

A
  • Parallelogram
  • Shows data into algorithm or outputs from it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does an arrow show in a flow chart?

A
  • Sequence of steps in the algorithm
  • Usually vertical or horizontal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is a flow chart?

A

Visual representation of the sequence of steps in an algorithm

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

What is a constant?

A

A storage location used to store a value that never changes as the program runs

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

What is assignment?

A

Giving a variable or constant a value by linking a value to the identifier

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

What is an identifier?

A

A unique name given to a variable or constant in your algorithm which makes your algorithm easier to read and understand

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

What is pseudocode?

A

A structured, code-like language that can be used to describe an algorithm

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

What are keywords?

A

Used in pseudocode for common operators; written in capital letters

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

What are some example keywords?

A

INPUT- Getting values into the algorithm from user via keyboard
OUTPUT- Messages or results displayed on screen

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

What are the pseudocode arithmetic operators for addition, subtraction, multiplication and division?

A

+ , - , * , /

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

What are the pseudocode arithmetic operators for integer division and modulus?

A

DIV (only evaluates quotient which is the integer)
MOD (only evaluates remainder)

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

List all the comparison operators (and what they evaluate to)

A

< - Less than (True)
> - Greater than (False)
== - Same as (True)
!= - Not equal to (True)
<= - Less than or equal to (True True)
>= - Greater than or equal to (True False)

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

True or False: Arithmetic Operators are evaluated AFTER comparison operators

A

False, evaluated BEFORE.

27
Q

What are the three Boolean operators?

A

AND - Checks both conditions are true or false
OR - Checks EITHER conditions is true
NOT - Reverses Boolean Value (e.g x>y = False, NOT reverses evaluation to True)

28
Q

What is an operator?

A

Symbol that shows an operation

29
Q

What are the three basic programming constructs ?

A
  • Sequence
  • Selection
  • Iteration
29
Q

What is an exponentiation?

A

Base integer is raised to power of exponent integer, Operator is ^

30
Q

What are the two types of iteration?

A
  • Condition- controlled loop
  • Count-controlled loop
31
Q

What is nesting?

A

Combining code together, putting a while loop inside a while loop

32
Q

What is an array?

A

Data structure that allows storage of multiple items in a single variable

33
Q

What is a subprogram?

A

Clear, independent blocks of code within a computer program which can be called and accessed by main program

34
Q

What is ‘call’?

A

Starting the subprogram

35
Q

What are subprograms which return values known as?

36
Q

What are subprograms which don’t return values known as?

A

Procedures

37
Q

What is decomposition?

A

Breaking problem down into smaller sub-problems until these tasks are solved

38
Q

What is a string?

A

A sequence of characters surrounded by quotation marks

39
Q

What is concatenation?

A

Merging or joining two strings together using a concatenation operator (+)

40
Q

What is abstraction?

A

Process of removing unnecessary details from a problem

41
Q

What is time efficiency?

A

The number if steps to complete the algorithm

42
Q

What is space efficiency?

A

The amount of memory required to complete the algorithm

43
Q

What is brute force?

A

Process that tries all possible alternatives to find a solution

44
Q

How are data values within a program stored?

A

Either as variables or constants which serve as placeholders that reference specific memory locations

45
Q

True or False: Each variable or constant is design to contain multiple data items at any given time.

A

False, while a program can encompass numerous variables and constants, each is designed to contain a SINGLE data item at any given time.

46
Q

What are the common data types and what are they used for?

A

Integer - Whole Numbers, both positive and negative
Real - Employed for numbers with fractional components, including decimals
Character (char) - Holds single characters (e.g. letter, digit, symbol)
String - Stores a sequence of characters.
Boolean - Representing truth values

47
Q

Why is a variable name important?

A

Used by program to reference a specific memory location where the associated data is stored.

48
Q

What happens when a new value is assigned to a variable?

A

Old value is overwritten and lost unless it’s stored elsewhere

49
Q

What is snakecase?

A

Variables are written in lowercase with words separated by an underscore (first_name)

50
Q

What is camelcase?

A

Variables are written in lowercase without any spaces and after first word each new word starts with capital letter (firstName)

51
Q

What is pascalcase?

A

Variables are written the same as camelcase but first word also starts with capital letter (FirstName)

52
Q

What is the difference of a constant compared to a variable?

A
  • Once a value is assigned to a constant, it remains fixed and cannot be changed while program is running
  • Offer a way to define consistent values and are only declared and assigned once
  • Can be referred to repeatedly without worrying about accidental modifications.
53
Q

What is the primary advantage of a constant?

A
  • Provide single point of change (only one location needs modification) if a decision to modify value or precision in future
  • Improves maintainability and reduces risk of introducing errors
54
Q

What are inputs?

A

Data that a program receives or and processes . Come from variety of sources, including user input, files, sensors and networks

55
Q

What are outputs?

A

Results of a program’s processing which can be displayed on screen, printed out or sent other devices or programs.

56
Q

How can data retrieved by an input function be made use of?

A

Assign the return value to a variable or the input value will effectively go unused and program will proceed with execution

57
Q

What do programming constructs provide?

A

Structural framework for creating programs and define how instructions and data are organised an manipulated within a program.

58
Q

What can programmers create using programming constructs?

A

Algorithms and logical structures that achieve specific tasks and solve problems.

59
Q

What does the sequence construct involve?

A
  • Executing series of statements in specific order, following linear flow of program
  • Foundation for building step-by-step logic that characterises most programs
60
Q

What does the selection construct involve?

A
  • Enables program to make decisions based on conditions
  • Evaluating whether certain conditions are true or false then executing different sets of instructions accordingly
  • Introduces branching and enables programs to adapt to different scenarios
61
Q

What does the iteration construct involve?

A
  • Also known as looping
  • Allows set of instructions to repeat multiple times as long as a certain condition remains true
  • Crucial for automating repetitive tasks and creating efficient, data-driven processes
62
Q

What happens when the sequence construct is ignored and instructions are executed in wrong order?

A
  • Logic Errors: May not perform designed task or might produce incorrect outputs due to flawed logic
  • Unexpected Results: Incorrect sequencing can lead to unseen results which make it challenging to troubleshoot and identify root cause
  • Crashes: In extreme cases, incorrect sequence could cause crashes, freeze or undefined behaviour
63
Q

What are the two types of iteration?

A

Count-controlled iteration - Number of times the loop is executed is predetermined before loop starts
Condition-controlled iteration- Loop continues to execute until certain condition is met