Exam 3- 2011

Consider the following unsorted list breakfast coffee

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Using the bonuses dictionary, print that employee’s total salary. For a given employee: Total salary = base salary + bonus (if any). CS 115 Exam 3, Fall 2011 Page 3 of 11 Problem 2: 15 points. Consider the following unsorted list: breakfast = ['coffee', 'pancakes', 'waffles', 'juice', 'banana', 'yogurt', 'cereal', 'bacon', 'toast', 'donuts'] and the following selection sort (which is essentially identical to your lab code): def selection_sort(list_to_sort): for i in range(len(list_to_sort) – 1): min_index = find_min_index(list_to_sort[i:]) + i list_to_sort[i], list_to_sort[min_index] = list_to_sort[min_index], list_to_sort[i] def find_min_index(L): return L.index(min(L)) In the diagrams on the next page, show the contents of the 10-element array after each of the first 4 iterations of the for-loop in selection_sort. For your reference, the sorted version of the list appears in Question 3 on the following page. If the list does not change from one iteration to the next, you can write “SAME” for the n...
View Full Document

Ask a homework question - tutors are online