1.9 Algorithms and Programs Flashcards
What is an algorithm?
An algorithm is a set of mechanical and sequential steps that are followed in order to take an input and process it in to an output
Considerations when using inputs and outputs
Data types, Structure of the data, validation, number of arguments, where the input/ouput will go, are the any preconditions
what is a variable
A variable is a named location in the computers memory that a programmer can use to store data whilst the program is running
what is a constant
A constant is a variable that cannot be changed during the duration of the program
global variables
Can be used throught the entire program
Local variables
Can only be used within their subroutine
What are the two kinds of subroutines
Procedures, functions
What are procedures
Procedures are subroutines that don’t return a value, normally used to output something
What are functions
Functions are subroutines that return a value
What are the two different search algorithms
Binary, linear
what are the benefits of binary search algorithms
They are efficient
What are the disadvantages of binary search algorithms
They require the data set to already be sorted
what are the advantages of linear search algorithms
They don’t require sorted data sets
They can search through data sets that hold different kinds of data
What are the disadvantages of linear search algorithms
They are slow if the data set is long