Algorithms Flashcards

1
Q

Define A Problem

A

A problem refers to anything that requires a computational solution

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

Define Problem Solving

A

This is the process or act of finding a solution to difficult or complex issues. Or The process of working through details of a problem to reach a solution.

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

Identify all the steps in the problem solving process:

A
  1. Identify & Define the Problem
  2. Analyze the Problem
  3. Identify Possible Solutions

4.Select & Develop the Best Solution

  1. Test algorithm
  2. Coding and implementation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Define the term Algorithm

A

A set of sequential steps usually written in Ordinary Language used to solve a given problem

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

Define the term narrative

A

A narrative is a detailed worded representation of an algorithm. It is explicit in its depiction of the steps that must be followed to produce the desired results.

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

List and explain the properties of an algorithm

A

FINITE: Must terminate.

UNAMBIGUOUS: Must be clearly stated.

EFFECTIVE: Must be easy to convert to program statement

GENERAL: Must be complete to solve specific problems for any relative input data

INPUT/OUTPUT: Must take zero, one or more quantities as input and produce one or more output values.

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

What is a psuedocode?

A

Pseudocode: A pseudocode is a step by step solution to a problem which is written using English-like statements and mathematical notations to explain the logics in solving a problem. Pseudocodes do not conform to any particular programming language’s syntax; they must however, be written in such a way as to allow them to be translated line by line into source code.

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

Define the term ‘flow chart’

A

A flowchart is a pictorial representation of the sequence of instructions required to solve a problem.

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

Explain and give an example of the ‘repeat until’ loop

A

The repeat until loop is the type of loop that keeps on carrying out a command or commands UNTIL a given condition is satisfied, the condition is given with the UNTIL command, for example:-

PROBLEM: To wash a car

ALGORITHM:

1 REPEAT

2 wash with warm soapy water

3 UNTIL the whole car is clean

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

Explain and give an example of the ‘while’ loop

A

In this type of loop the condition is given along with the WHILE command and the loop keeps on carrying out a command or commands until an END WHILE command is given.

example:

PROBLEM: To ask for a number more than 10, then stop when such a number is given

ALGORITHM:

1 WHILE number given is less than 10

2 ask for a number more than 10

3 END WHILE

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

Explain the ‘for loop’

A

A FOR loop keeps on carrying out a command or commands, FOR a given number of times. In this type of loop the number of times it is repeated must be known. The commands to be repeated are sandwiched between the FOR and END FOR commands.

For example:-

PROBLEM: To print the numbers from 10 to 20

ALGORITHM:

1 FOR number = 10 to 20

2 Print number

3 END FOR

Example 2:-

PROBLEM: To print the 13 times table from 1 x 13 to 10 x 13

ALGORITHM:

1 FOR z = 1 to 10

2 Print 13 x z

3 END FOR

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

List and explain Properties of algorithms

A

Finiteness: The algorithm must always terminate after a finite
number of steps.

Definiteness: Each step must be precisely defined; the
actions to be carried out must be rigorously and unambiguously
specified for each case.

Input: An algorithm has zero or more inputs, taken from
a specified set of objects.

Output: An algorithm has one or more outputs,
which have a specified relation to the inputs.

Effectiveness: All operations to be performed must be
sufficiently basic that they can be done exactly and in finite length.

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

List and explain characteristics of a good algorithm

A

Precision– the steps are precisely stated (defined).

Uniqueness– results of each step are uniquely defined and only depend on the input and the result of the preceding steps.

Finiteness– the algorithm stops after a finite number of instructions are executed.

Input– the algorithm receives input.

Output– the algorithm produces output.

Generality– the algorithm applies to a set of input

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