Unit 3 - Algorithms and data structures Flashcards
What is an algorithm?
A set of rules of instructions for completing a task.
Why don’t algorithms give perfect results?
The perfect result is not efficient and takes a lot more time than ‘good enough’.
What type of problems are algorithms very useful for?
Recurrent problems where you can perform the same task over and over again.
What is a flowchart?
It is used to translate human instruction into computer instruction.
What is a terminator in a flowchart?
It is used at the beginning and end, representing the external node of a flow. You use an oval.
What is a Process in a flowchart?
A rectangle representing a process such as data calculation or filtering.
What is a decision in a flowchart?
Diamond shaped indicating a choice and multiple possible paths.
What is input/output in a flowchart?
A parallelogram, data is sent into or out of the process.
What does an arrow do in a flowchart?
It represents the direction of the flow.
What is a stack?
It is a data structure with the philosophy Last in, First Out (LIFO)
What operations does a stack have?
Push: Add a new item to the top. Used to populate the stack with data.
Pop: Removes the top piece of data from the stack. Used to read the value and then remove it.
What are characteristics of a stack?
Takes up a low amount of space, but cannot be searched randomly. Random Access Memory is not possible with Stack.
What is a linked list?
It is a sequential storage structure where each element is linked to the next. The last element has no pointer and so points to null.
You can insert elements in the middle of the sequence, but it is still allowing quick access. More flexibility than a stack.
There is no restriction on number of elements. It is unbounded.
What is an array?
A sequential data structure. Takes more memory but allows for random access for reading and writing. They are usually bounded meaning they have a predetermined size.
Each element has an index that identifies it, starting at 0.
What is a multi-dimensional array?
Imagine a checkerboard, you give coordinates to the array. You can have more than two dimensions but this makes it a lot more complex.
Checkerboard[3,5] “Red