Master Computers and Technology with Fun Quizzes & Brain Teasers!
Given the array [13, 1, 3, 2, 8, 21, 5, 1] suppose we choose the pivot to be 1 the second element in the array. Which of the following would be valid partitions? A. 1 [1, 2, 3, 5, 8, 13, 21]B. 1 [13, 1, 3, 2, 8, 21, 5] C. 1 [13, 3, 2, 8, 21, 5, 1] D. [1] 1 [13, 3, 2, 8, 21, 5] E. [13] 1 [3, 2, 8, 21, 5, 1] F. [13, 1, 3, 2, 8, 21, 5] 1 2/4
1. Implement the function dict_intersect, which takes two dictionaries as parameters d1 and d2, and returns a new dictionary which contains only those keys which appear in both d1 and d2, whose values are a tuple of the corresponding values from d1 and d2. E.g., dict_intersect({'a': 'apple', 'b': 'banana'}, {'b': 'bee', 'c': 'cat'}) should return {'b': ('banana', 'bee')} 2. Implement the function consolidate, which accepts zero or more sequences in the star parameter seqs, and returns a dictionary whose keys consist of values found in those sequences, which in turn map to numbers indicating how many times each value appears across all the sequences. E.g., consolidate([1,2,3], [1,1,1], [2,4], [1]) should return the dictionary {1: 5, 2: 2, 3: 1, 4: 1}.