Unit 6 Flashcards
(40 cards)
What is an algorithm
A set of instructions for solving a problem or completing a task
What is algorithmic thinking
A way of getting to the solution by identifying the steps required
What is abstraction
Removing unnecessary detail from a problem so you can focus on the essential
Relevant features are identified
What is decomposition and the advantages
Breaking down a problem into smaller sub problems and breaking them down further so they are manageable
A problem becomes easier to solve when it consists of a number of smaller tasks/modules and they may be reusable later in the problem/program saving development time
What is a binary search
The program analyses the middle item in the list
It works out if the item its looking for is above or below in the list (or that item is the item being looked for)
If above then the bottom half of the list is deselected
If below then top half of list is deselected
Repeat process until program has found the item
(If there is an even number in the list, ie: 2, the middle item would be the 1st out of the 2 items in the middle)
(only works in a sorted list)
What is the amount of searches necessary for the worst case scenario in a binary search
In a list of 2^n items the worst case scenario will be n + 1 number of times searched
If the n isn’t a whole number (ie: 1,000,000 items in the list), then you would need to find the closest integer n and add one (ie: 2^19 is less than 1M and 2^20 is over 1M so the worst case scenario would be 20 searches)
What is a linear search
When the program checks the list one by one to find the required item
What is a bubble sort and how many passes will the algorithn have
Starting from the first, each items is compared to the item next to it in the list. If the item to the right is smaller, they switch and if not they stay the same
The program moves onto the next 2 items in the list (including the 2nd item in the list from the 1st sorting). so if the previous sorting was the 1st and 2nd item, this would be the current 2nd item and 3rd item
The program sees if they are in the right order, switches if necessary and move onto the next (3rd and 4th). This continues until the program reaches the end of the list where one item will be successfully sorted (the last one)
Then the program goes again, starting from the bottom of the list and makes it way back up to the top. Now the 2nd to last item will be sorted.
The amount of passes an algorithm will have is the number of items in the list - 1
What is an insertion sort
the algorithm sorts data one item at a time: One item is taken and placed in the correct position and this repeats until there are no more unsorted items
The first item will remain unchanged as there is nothing to sort it against. The 2nd item will be sorted accordingly to the first. If it is larger then it will stay but if it is smaller it will go to the back. This repeats for all items and they get inserted to their correct position
What is merge sort
The list is broken down into smaller lists (divide by 2 or split) until there are many lists with just one item. Then the program takes 2 lists (presumable the ones next to each other) and merge them into one list by inserting them into the correct spot, making a sorted list of 2. This repeats for the whole list making many sorted lists of 2s.
To correctly sort 2 lists of 2s into one list of 4, let’s say the first item in list 1 is A then B. the 1st item in list 2 is C then D. We compare items C and A and decide which is smaller. If item C is smaller that goes in the new list. Then item A and D are compared. If item A is smaller that goes in the list and then item B and D are compared and sorted as so.
This process continues until there is just one list that is fully sorted
what is the order of how fast each sorting type is
1) Merge sort
2) Insertion sort
3) Bubble sort
What do the MOD and DIV operators do
MOD: Finds the remainder of a division
DIV: Integer division (only outputs the integer of the division)
What is a variable
A location in memory where you can temporarily store text or numbers
When you write a statement such as
total = mark1 + mark2
what variables are you assigning to a variable (total)
total
mark1
mark2
What do each flowchart operation mean
Start
End
Input
Output
Calculation/Assignment
Decision
Oval
Oval
paralellogram
paralellogram
Rectangle
Diamond with yes and no statements coming out the sides
What does the statement count = count + 1 mean
add 1 to the variable called count
What are the 3 programming constructs/structures
Sequence - regular statements that don’t affect which line the program will go to next (It will just go to the one under it)
Selection - if statements/elif statements or switch /case
iteration - while/for loops or do until loops
Computational Thinking definition
the thought process involved in formulating problems so their solutions can be represented as computational steps and algorithms
problem inputs definiton
The data or information provided to program an algorithm, complete a set task or solve a proble
problem processes definition
steps or operations that a program or algorithm performs to solve a specific problem
Problem output definition
The result or output delivered after an algorithm or program has finished processing given inputs.
What are the 3 aspects of computational thinking
Algorithmic thinking
Abstraction
Decomposition
What is an integer
A whole number (including negatives)
Real
Number with a decimal point