3_1_4 Sorting Algorithms
You should be able to:
- Understand and explain how the merge sort algorithm works.
- Understand and explain how the bubble sort algorithm works.
- Compare and contrast merge sort and bubble sort algorithms.
REVISE:
REVISE:
TEST:
TEST:
- Download and print the test paper here: https://drive.google.com/open?id=0B5fLtQ0Xgr2PcFo2T1lPTUo2LVE
- Try the mock test yourself.
- Use the 3.1.4 Walking Talking Mock below to guide you through answering the questions.
Programming Task
Programming Task
Program a bubble sort in Python! Watch the video for a guide on how it could work:
The code I used is here but you might want to try to make it more efficient!
myList = [4,234,232,121,1,323,1,2,3,0,2,3,23,45,23]
count = 1
swapsLeft = count>0
while swapsLeft:
count=0
for x in range(0,len(myList)-1):
y=x+1
if myList[x]>myList[y]:
count+=1
a=myList[x]
b=myList[y]
myList[x]=b
myList[y]=a
print (myList)
swapsLeft = count>0
SOURCE RECOGNITION - PLEASE NOTE: The examination examples used in these walking talking mocks are samples from AQA from their non-confidential section of the public site. They also contain questions designed by TeachIT for AQA as part of the publicly available lesson materials.