Please enable JavaScript.
Coggle requires JavaScript to display documents.
Fundamentals of Algorithms (Pseudo Code (Must contain statements which…
Fundamentals of Algorithms
Algorithms
A set of step by step instructions which have to be followed in order to complete a task or achieve a desired outcome
Judging the success of an algorithm
Accuracy - Must lead to the expected outcome
Efficiency - Must solve problem in shortest possible time
Consistency - The same result must be produced each time
Algorithm efficiency
Total Lines of code (the less the faster it is)
Run time (how long solutions takes to produce result)
Memory required (the less required the better)
Flowchart Symbols
Rectangle - Process - Indicates something that happens in the algorithm
Diamond - Decision - Represents where choices are made
Oval - Initiator/Terminator - Indicates the start or end of a flowchart
Parallelogram - Input/Output - Indicates where data is entered or outputted from the system
Pseudo Code
Must contain statements which describe processes/actions
Has to focus on the logic of the algorithm or program
Contain no specific programming language syntax
Be directly translatable into the desired programming language syntax
Use indentation and show clearly numbered steps
Decomposition
The process of breaking a problem down into small subtasks
The outcome of this is to produce a list or diagram which shows the subtasks which when combined produce a solution to the overall problem
Abstraction
This is a process that involves removing irrelevant information
It makes a problem which is hard to understand and complex, easier to understand and simpler
Trace Tables
It's purpose is to track the changes in the variables or data items the algorithm uses
Every time a variable or data item changes, the trace table is updated
A trace table can help you to understand what happens within that algorithm
Input - Process - Output Model
All computers have the same four basic components
Input - Data enters computer through an input device
Output - The processed data is communicated out the system
Data (before processing) or information can be kept in the system until it's needed
Process - An action is applied to the incoming data and it is changed into information
Searching
Linear Search
Disadvantages
Slow and inefficenct
Bad for a big amount of numbers
Person enters data they want retrieved
Advantages
Good for small amounts of numbers
Easy to code
The linear search looks at the pieces of data one by one until it finds what the person requrested
Binary Search
In this search the middle item is selected and the program checks if that number or piece of data is higher or lower than the one being searched for
If the number is lower, in an ascending list, it removes all the numbers to the left of the one selected and the one selected
Advantages
Fast and efficient
Good for huge amounts of numbers
Disadvantages
Requires an ordered list
Takes long time to code
In a list with an even amount of numbers the value to the left of the middle is taken as the middle value
Sorting
Bubble Sort
Two numbers are compared, is sorting in ascending order you put the higher number on the right
Then the second and third number get compared, third and fourth and so on
Disadvantages
A lot of writing if done on paper
Only compared two numbers at a time
Slow
Does lots of irrelevant steps
Once all the numbers are compared the first pass is completed,
Advantages
Good for small amount of numbers
Easy to use
Simple
Does the sort thoroughly
Then the same thing is done but the last number is not compared as it is the biggest one
Merge Sort
The list splits in half and then those lists split. All the lists keep splitting until every list has 1 value
Lists then compare in pairs of two and sort themselves out, then those lists merge
Disadvantages
Takes long to code
Hard to code
They keep comparing until you get one big list sorted out
Advantages
Not many irrelevant steps
Does multiple steps at the same time
Efficent
Works with a big amount of numbers