Unit 2 - J276 Flashcards
Computational thinking is all about the ______ taken to find the best ________ to a complex _________.
stages, solution, problem
Abstraction - Picking out the _________ bits of information from the ________ whilst _______ the specific ______ that don’t matter
important, problem, ignoring, details
Decomposition - _________ a complex ________ into smaller ________ and ________ each one __________.
Splitting/Breaking, problem, problems, solving, individually
Algorithmic thinking - using a series of ______ steps to find ________ to a ________. - Algorithms can be ______ and ______ to solve ______ problems in the _______.
logical, solutions, problem, reused, adapted, similar, future
The 3 types of Computational thinking are
- __________
- D_________
- ___________ thinking
Abstraction
Decomposition
Algorithmic Thinking
Searches allow a set of ____ to be _______ in order for a specific ____ to be ______.
data, examined, item, found
The 2 types of searching ________ are
- ________ search
- ________ search
algorithms
Binary Search
Linear Search
Binary search looks for items in an ______ list.
1) Set _______ to the ______ position in the list
2) If the ______ value matches, the search ___
3) Otherwise, if the desired _____ is less than the _______, then the _____-____ of the list is ______ and the search keeps to the _____-___ of the list
4) Or, if the desired _____ is more than the _______, then the _____-____ of the list is ______ and the search keeps to the _____-___ of the list
5) Steps _ to _ are _______ until a ______ is found or there are no more items to be ______.
ordered,
counter, midpoint
desired, ends
value, midpoint, upper-half, ignored, lower-half
value, midpoint, lower-half, ignored, upper-half
2-4, repeated, match, found
A binary search is much more _______ algorithm than a _______ search - In an ordered list of every number from 0-100, a linear search would take __ steps to find the number 99, whilst a binary search will find it in just 7 steps
Binary search only works for _______ lists tho ;(
efficient, linear, 99 steps
ordered
A linear search can be used on an ________ list.
Starting at the ________ of the data set, ____ item of data is _______ until a ______ is found or there are no more ______ to find.
unordered
beginning, each, examined, match, items
A way to describe a linear search would be
1) Find out the _______ of the data ___
2) Set _______ to 0
3) ________ value held in the list at the _______ positon
4) ______ to see if the value at that ________ matches the ______ value
5) If it _______, the value is found and the search is ____.
6) If not, ________ the counter by __ and go back to step 3 until there are no more ____ to ______
length, set
counter
Examine, counter
Check, position, desired
matches, ended
increase, 1, items, find
Linear searches are ______ to make due to its ________ and they work on both _______ and ________ lists.
Although, they can be quite _______. - Suppose a list contained 100 items, and the 99th item had to be found, 99 steps would have to be taken to find that single item.
easy, simplicity, ordered, unordered
inefficient
A ______ search in psuedocode might look like this
find = 2 found = Falselength = list.length counter = 0 while found == False and counter < length if list[counter] == find then found = True print ('Found at position', counter) else: counter = counter + 1 endif endwhile if found == False then print('Item not found') endif
.
A _______ search in psuedocode might look like this
find = 11 found = False length = list.length lowerBound = 0 upperBound = length while found == False midpoint = int((upperBound + lowerBound))/2 if list[midPoint] == find then print('Found at' , midPoint) found = True else if list[midPoint]> item then upperBound = midpoint-1 else lowerBound = midpoint+1 endif endif endwhile if found == False then print('Not found') endif
.
The 3 methods of sorting are
- B______ Sort
- M_____ Sort
- I________ Sort
Bubble Sort
Merge Sort
Insertion Sort
A bubble sort is the ______ of sorting algorithms. It works like this.
1) Start at the _______ of the list
2) Compare the ____ value in the list with the ____ one up. If the _____ value is bigger, _____ the positions of the ____ values
3) Move on to the ______ value in the list. Again, _______ this value with the next and swap if the value is ______.
4) Keep going until there are no more _____ to ________
5) Go back to the _____ of the list
simpliest
beginning
first, next, first, swap, two
second, compare, bigger
items, compare
start
Each run through the list, from _____ to ______ is known as a _____.
A bubble sort continues until a ____ is made where no ______ have been _______ - This is when the list is completely ______.
start, finish, pass
pass, values, swapped
sorted
The advantages of a bubble sort are
- Easy to ________ due to its simplicity
- Efficient if the list is in ______
- Not much _______ is used as all the sorting is done on the ________ list
implement
order
memory, original list
The disadvantages of bubble sorts are
- _________ for large list
- An extra ____ occurs even if the list is in ______.
Inefficient
pass, order
A psudeocode algorithm for a bubble sort might be
counter = 0 swapped = True swaps = 0 length = list.length while swapped == True while counter < length-1 if list[counter] > list[counter+1] then temp = list[counter] list[counter] = list[counter+1] list[counter+1] = temp swaps = swaps + 1 endif counter = counter + 1 endwhile if swaps == 0 then swapped = False else: swaps = 0 counter = 0 endif endwhile
.
A merge sort ______ a list apart then ______ it back together in its ______ order. - It is an example of a ______ and _______ algorithm.
splits, merges, sorted, divide and conquer
A merge sort works like this.
1) Split the list in _____ to form ___-____ ( the second sublist should start with the ______ term for odd no. of items)
2) Keep ______ step 1 until each ___-_____ only contains ____ item
3) Merge pairs of ____-____ so that each ___-____ has _____ as many items. Each time you merge ____-____, ____ the items in the correct ______
4) ______ step 3 until you have _____ all ___-____ together
half, sub-lists, middle
repeating, sub-list, one
sub-lists, sub-list, twice, sub-lists, sort, order
Repeat, merged, sub-lists
The advantages of merge sorting
- More _______ and _______ than ______ and insertion for ______ lists
- Very consistent _______ ____ regardless of how the items in a list are ______
efficient, quicker, bubble, large
running time, ordered
The disadvantages of merge sorting
- Slower than other algorithms for _____ lists
- Still performs the _____ and _____ process even if the list is already _____.
- Uses more _______ than other algorithms as it creates ________ lists
short
split/divide, merge/conquer, sorted
memory, separate additional