Share/ 27c891fe15254a41a2 5539e68cab7a02: Worksheet:1
Share/ 27c891fe15254a41a2 5539e68cab7a02: Worksheet:1
Sessio Gist of Lesson Expected Learning Teaching Suggested material / Assessment Worksheets
n Outcomes/ELO Learning Resources strategies
activities planned planned/Assignments
/Practical
Link to PPT
WORKSHEET 1
1 Why do number of comparisons reduce in every successive iteration in Bubble sort?
3 Write a program to perform insertion sort on a list of numbers. Create the list by accepting values from the user.
4 What will be the status of following list after fourth iteration of bubble sort in ascending order?
93, 10, 34, -2, 16, 83, 26
WORKSHEET 2
1. What is sorting? Name some sorting techniques.
2. Given a list 34,56,7,2,0,8 Sort the list in ascending order using bubble sort. Show the contents of the list after each
pass.
3.
Carefully examine the image and identify which sorting algorithm is used to sort
the list
#INSERTION SORT
def insertion(): #Function
l=[27,4,15,3,5,19,10,2,1] #list
print("Original List:", l,'\n')
n=len(l) #store number of elements in n
for i in range(1,n): #outer for loop
j=i
while j>0: #inner loop
if l[j-1] > l[j]:
l[j-1],l[j] = l[j],l[j-1] #swapping
else:
break
j=j-1
print("List after pass", i,":", l)