Master Computers and Technology with Fun Quizzes & Brain Teasers!
Implement a binary search function in three substantially different programming languages. In each program (identical, except for the programming language), carry out the same 10,000,000 unsuccessful searches for eight different-sized arrays, namely arrays of sizes 128, 512, 2048, 8192, 32768, 131072, 524288, and 2,097,152. Measure in each of the three programs the time it takes to do the 10,000,000 searches for each of the eight arrays. Compare these timings to the theoretical timings the algorithm binary search provides. Are there differences between the three programs? Explain your timings and observations!!
Given integer values for red, green, and blue, subtract the gray from each value.Computers represent color by combining the sub-colors red, green, and blue (rgb). Each sub-color's value can range from 0 to 255. Thus(255, 0, 0) is bright red, (130, 0, 130) is a medium purple,(0,0,0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50,130) is a faded purple, due to the (50, 50, 50) gray part. (In other words, equal amounts of red, green, blue yield gray).Given values for red, green, and blue, remove the gray part.
Create a function min_mid_max which takes a list as its formal parameter and returns a new list with the following characteristics: element 0 contains the minimum value element 1 contains the middle value (not the median -- which would require an average if the list had an even number of elements). If the list is even (e.g. [1,2,3,4]) the 'middle' value will be the right value of the two possible choices (e.g. 3 rather than 2). element 2 contains the maximum value Notes: You can only use Python syntax shown so far (even if you know more) You cannot use any math library (we have yet to see this) You should use the function sorted. Remember the function sorted does not change its input, it returns a new list. You should only need to call sorted one time. print(sorted(3,2,1])) You can use the function int (another built in function) to help determine the index of the middle value. This function takes a floating point (or any kind of number) and converts it into an integer (e.g.print(int(4.32)). This will allow you to treat lists with an even number of elements the same as a list with a odd number of elements. If min_mid_max is called with an empty list, return an empty list. If min_mid_max is called with 1 item that item is the min, mid, and the max If min_mid_max is called with 2 items, the mid and the max should be the same No need to worry about the incoming list being the value None