Algorithms Flashcards

(16 cards)

1
Q

Define algorithm

A

A set of rules to solve a specific problem

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

Why are algorithms designed with no specific programming language

A

So that the algorithm can be implemented in whichever programming language the developer chooses to use later

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

Give 3 types of algorithm

A

Pseudocode
Structured English
Flowcharts

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

What is the difference between a variable and a constant

A

Variable
Value can change

Constant
Given one value which stays the same throughout a program

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

What are constants used for

A

Improve readability of code
save having to re-enter values in multiple places

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

Outline 5 ways in which a programmer may make a program easier to understand

A
  • self documenting identifiers;
    Variables, procedures, constants, buttons,
    Code can be followed and reduces need for additional annotation

Annotation-
Comments can be added to record developmental process and logic

Layout-
Indentation to make nesting easier, iteration
Improved quality of software, maintain standards

Constants

Avoid using global variables where possible-

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

Outline the meaning behind a scope and lifetime of variables

A

Scope
The parts of the program in which the variable can be accessed

Lifetime
The duration of time for which the variable holds the value of the execution of a program

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

Describe the advantages of using subroutines

A
  • makes program easier to understand by splitting into smaller chunks
  • easier to test each procedure in isolation before using with the rest

-allows team working

  • procedures can be re-used in future programs
  • compile procedures and put them in subroutine libraries so they can be called from other programs

-

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

What is a parameter

A

Values that can be sent to a procedure and/or received from a procedure

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

Describe value parameters

A

Used to pass information into a procedure but don’t receive information

Sending a copy of the parameter to the procedure so any changes made are to the copy and not original

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

Outline 7 validation techniques

A

Range check- between min and max
Presence check- has been entered
Length check
Type check- correct type
Format check- m/yyy
Lookup check- confirmed
Check-digits- coded numbers for identification

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

Describe verification

A

Checking to see if the data entered is consistent

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

What is a factorial

A

Recursion
Factorial(n) = n x Factorial(n-1)

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

State 3 ways to identify a recursion

A

Calls itself
Has a terminating condition
When it calls itself it passes one or more parameters

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

Outline As and Ds for recursion

A

Requires less code and therefore more elegant
A natural way of thinking about the program

When it runs, it can use more memory bc it needs to keep track of each of the multiple calls to the procedures
Debugging can be more difficult because when an error occurs, it’s not easy to work out which level the error occurred

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