Question: need help on 2 and 5. pleases help asap!!!!!! Given an already sorted list of 6 elements, how many comparisons of list elements would each

need help on 2 and 5. pleases help asap!!!!!!

need help on 2 and 5. pleases help asap!!!!!! Given an already

Given an already sorted list of 6 elements, how many comparisons of list elements would each of the following algorithms perform? Explain each answer briefly. selection sort insertion sort mergesort bubble sort Let's say that you want to implement a method findMode (alist) that takes a list of integers and returns the mode of the values in the list - i.e., the value that appears most often in the list. For example, the mode of the list {10, 8, 12, 8, 10, 5, 8} is 8. If two or more values are tied for the mode, the method should return the smallest of the most frequently occurring values. For example, in the list {7, 5, 3, 5, 7, 11, 11}, three values (5, 7, and 11) each appear twice, and no value appears more than twice; the method should return 5 because it is the smallest of the three values that appear twice. One possible implementation of this method is: def findMode(alist): mode = -1 modeFreq =0 # number of times that the mode appears for i in range(len(alist)): freq =1 # number of times that alist [i] appears from # position i to the end of the list for j in range(i + 1, len(alist)): if alist [j] == alist [i]: # how many times is this executed? freq = freq + 1 if freq > modeFreq or \ (freq == modeFreq and alist [i]

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!