chapter 1: Algorithms pp Flashcards

1
Q

Definition

An algorithm

A

is a set of instructions that leads to a deterministic
result in a finite time, once it is correctly executed.

A written set of instructions is called a program or algorithm.

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

What does an Algorithm consist of?

A

A computer algorithm is a set of instructions in which we also findstructures and subprograms.:

  • Instructions for (declaring and) initializing variables (i.e.assigning initial value)
  • Input/output instructions
  • Conditional structures:
    1) Sequences
    2) Iterations
    3) Loops
  • Subprograms:
    1) procedures
    2) functions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

variable is characterized by:

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

The address

A

represents the physical place in memory for where the value of a variable is stored. Without these variables, one would have to remember the addresses in memory itself

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

primitive types

A

These are types that are an integral part of the programming language.

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

The instruction type(..)

A

allows us to find the type of a variable

at a specific point in time in Python.

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

The type “Character”

A

(a single character) is usually shown between singlequotation marks (for example, ’a’, ’6’, ’&’). So the value 6 differs fundamentally from the value ‘6’

However, in Python this type does not exist and is seen as a variant of the type str. In Python one can use both single and double quotes for the type str.

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

The structure of an Algorithm (and therefore every program) consists of three parts:

A

-> The name of the Algorithm:
It is important to choose the name as clearly as possible, since our programs do not yet have real functionality, the names will be meaningless for the time being.

-> A section in which the variables are declared.:
Since Python is a language with dynamic types, declaring variables is not necessary. Since declaring variables is indispensable in programming languages with static type
checking (such as Java), I choose to teach you this healthy habit by obliging you to document the data type.

-> A set of instructions and operations.

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

A variable is usually created in two steps:

A
  • First it is declared

- A value is then assigned to the variable by means of an assignment.

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

initialization.

A

Assigning an initial value to a newly declared variable is called initialization. The initialization (with a default value) ensures that if the memory reserved at the time of declaration is not empty, the program will not produce unexpected results.

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

a variable is declared:

A
  • This means that her name and data type are chosen.
  • The declaration ensures that the variable becomes part of the program, and
  • that a place of the correct size is reserved in the computer memory for storing a value.
  • At the time of the declaration, the memory is theoretically empty.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

sequential execution.

A

Algorithms are read and executed from top to bottom, line by line.

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

This state of the algorithm is defined

as

A
  • the value of all variables at a given time of execution

- the next instruction to be carried out.

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