Computer Science - Algorithms π©βπ» Flashcards
What is an algorithm?
An algorithm is a sequence of steps for solving a problem.
In computer terms, what is an algorithm?
In computer terms, an algorithm describes the set of steps needed to carry out a software task.
What are the main stages of solving a problem?
- Understanding the problem
- Defining the scope of a solution β the extent of
the facilities that the solution will provide - Creating the solution
- Documenting the solution
- Testing the solution.
- Creating the solution (go back to 3 until you get it right)
In what 3 ways can an algorithm be expressed?
Through natural languages, pseudocode, and flowcharts.
What is a variable?
A variable is a uniquely named location in memory (RAM), in which a single data item can be held while a program is running.
When can a variable change?
The program can change the value held in a variable during the time of the program execution. (When the program is open)
What is a memory location?
When a variable is declared, an area of the RAM is given to it.
What counts as a meaningful variable name?
A full, not shortened name that describes the variable.
What is a reserve name?
A keyword that cannot be used as a variable name. Some examples of reserve names are βIFβ, βINPUTβ, and βOUTPUTβ.
Can special characters be used in variable names?
The only special character that can be used in a variable name is underscore (β_β)
Can spaces be used in variable names?
No, instead, use camel case or underscores.
What is camelCase?
WhenWordsAreSeperatedByEachWordHavingCapitalLettersJustLikeThis.
What is an integer?
Integers are whole numbers, that can be positive or negative.
What are integers commonly used for in algorithms?
For counting, and whole number addition/subtraction.
What is a real data type?
Real data type is numerical data which contain decimal numbers
What are real data types commonly used for in algorithms?
Mainly used for money, weight, height, and temperature
What is a char data type?
Char data type can hold only a single character.
What is a char data type commonly used for in algorithms?
Mainly used for codes like T or F, or for single character things such as grades (S, A, B, C, D, E, F)
What is a string data type?
String data type consists of 1 or more characters (symbols)
What are string data types commonly used for in algorithms?
Mainly used for names, and address
What is a boolean data type?
Boolean data type represents a logical value. It can only represent 2 values.
What are boolean data types commonly used for in algorithms?
True or false, Yes or no, 0 or 1, etcβ¦
What is a constant?
Constants are data values which can be introduced at beginning of the program and cannot be altered by the program during execution.
What is pseudocode?
Pseudocode is one of the methods that could be used to represent an algorithm. It is not written in a specific syntax that is used by a programming language and therefore cannot be executed in a computer.
What does this symbol βπ β mean in pseudocode.?
It is the assignment symbol, which assigns a value to a variable.
How do you represent βless than or equal toβ in pseudocode?
<=
How do you represent βmore than or equal toβ in pseudocode?
> =
How do you represent βnot equal toβ in pseudocode?
<>
What is the INPUT command in pseudocode?
It simply accepts an input into the program, assigning it to a variable.
What is the format of writing an INPUT command in pseudocode?
[INPUT] β[INPUT prompt]β, [Variable name]
What is an INPUT prompt?
A string that contains helpful text prompting the user to enter something.
What is the OUTPUT command in pseudocode?
Itβs the act of returning (sending out) some information / data to the user of the program. This can be numerical, written, visual, or audio based.
What is the format of writing an OUTPUT command in pseudocode?
[OUTPUT] β[OUTPUT prompt]β, [Variable name]
What is an OUTPUT prompt?
A string prompting the user to identify the result that is produced by the program.
What is the DECLARE command in pseudocode?
Any variable/s to be used in the pseudocode can be declared (create) using the keyword DECLARE.
What is the format of writing a DECLARE command in pseudocode?
[DECLARE] [Variable name]: [Data type]
What is a program flowchart?
A pictorial representation of an algorithm.
What are symbols/boxes in flowcharts?
Standard shapes that represent different types of operations.