1 Understanding Algorithms Flashcards

To understand what is algorithm, why algorithms are used, interpretations of algorithms, Purpose of arithmetic operators

You may prefer our related Brainscape-certified flashcards:
1
Q

What is an algorithm?

A
  • Step-by-step instructions in how to solve a problem/ how to carry out a task
  • A specific accurate solution to a problem
  • A detailed design for a solution
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Characteristics of an algorithm

A
  • A solution to a problem
  • Unambiguous
  • Sequence of steps
  • It can be used again
  • It will provide the same result as long as the input is the same

Example:
Making coffee
* Pour 1 liter of coffee (Give clear, unambiguous instructions)
* Heat the water and turn off when appropriate (Unclear, ambiguous)

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

What is a successful algorithm?

A

A successful algorithm fulfills these three points.
* Accuracy - it leads to the expected outcome
* Consistency - it produces the same result each time it is run
* Efficiency - it solves problem in shortest possible time using fewest possible computer resources

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

Difference between algorithm and program

A
  • Algorithm - a detailed design of a solution to a particular problem
  • Program - A way of implementing that design
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Implementations of algorithms

A
  • Written description
  • Pseudocode
  • Flowchart
  • Program code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does a diamond shape represent in a flowchart?

A

*Selection
* indicates a decision to be made
* It produces True/False leading to two possible outcomes

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

What does a skew shape represent in a flowchart?

A

Input/output

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

What does an arrow shape represent in a flowchart?

A
  • Logical flow of the algorithm
  • It shows what steps to be taken next
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does a rounded rectangle shape represent in a flowchart?

A
  • Start/end
  • Terminal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What does a rectangle shape represent in a flowchart?

A
  • Process
  • Indicates a process to be carried out
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Flowchart

A
  • A diagram of implementation of algorithm
  • Provides more visual display
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Pseudocode

A
  • A structed, code-like language that can be used to describe an algorithm
  • Is relatively straightforward to translate into any high-level programming language
  • helps to focus on the logic and efficiency of the algorithm (without having to bother about the rules of any particular programming language)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Variable

A
  • A container that stores data(value)
  • The value in a variable is not fixed
  • Variable can store different values during the course of a program and each time a program is run
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Constant

A

A container that holds a value that never changes
* Pi value
* Number of m in km

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

Identifier

A
  • A unique name given to a variable or a constant
  • Using descriptive names can improve readability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Types of naming convention

A
  • snake_case
  • camelCase/CamelCase
17
Q

Variable and constant

A
  • both hold/store a value
  • both have unique identifier
  • Value in variable is not fixed while value in constant is
18
Q

Why is a variable useful?

A
  • The value in variable can change as a program is running
  • Variables let the same program to process different sets of data
19
Q

Operator

A

A character that represents an action

20
Q

Arithmetic operators

A

7 types
* Addition (+)
* Subtraction (-)
* Multiplication (*)
* Real division(/) - includes decimal places
* Quotient(DIV) - return whole number
* Modulus(MOD) - return the remainder
* Exponentiation(^) - power of