You are given two functions which are used in sequence as shown below. Nameless Function First blackbox function Input Bogosort + Output (List extender) А. The first blackbox function takes in as an...


Answer letter B only


You are given two functions which are used in sequence as shown below.<br>Nameless Function<br>First blackbox function<br>Input<br>Bogosort<br>+ Output<br>(List extender)<br>А.<br>The first blackbox function takes in as an input a list of integers. This list has a length of n and has at least<br>two unique integers. It then outputs n copies of that list as a single list.<br>E.g. If the input is [1,2,7], the output is [1,2,7,1,2,7,1,2,7]. If the input is [1,2,3,4] the output is<br>[1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4]. Design a function that performs this action. Can it be done in less than O(n)<br>time?<br>В.<br>The second function uses bogosort to sort a given input. What is the worst case time complexity of<br>bogosort? Why? If the input to your second function is the output of your first blackbox function is there a chance<br>no matter how small that bogosort does not enter the while loop? Why?<br>31<br>#bogosort pseudocode<br>Edef bogosort (list):<br>33<br>while list is notsorted:<br>shuffle(list)<br>С.<br>Say we replace the second blackbox function with bubble sort which has a worst case time complexity of<br>O(n^2). What is the worst case time complexity of the combined function (“Nameless Function Version 2

Extracted text: You are given two functions which are used in sequence as shown below. Nameless Function First blackbox function Input Bogosort + Output (List extender) А. The first blackbox function takes in as an input a list of integers. This list has a length of n and has at least two unique integers. It then outputs n copies of that list as a single list. E.g. If the input is [1,2,7], the output is [1,2,7,1,2,7,1,2,7]. If the input is [1,2,3,4] the output is [1,2,3,4,1,2,3,4,1,2,3,4,1,2,3,4]. Design a function that performs this action. Can it be done in less than O(n) time? В. The second function uses bogosort to sort a given input. What is the worst case time complexity of bogosort? Why? If the input to your second function is the output of your first blackbox function is there a chance no matter how small that bogosort does not enter the while loop? Why? 31 #bogosort pseudocode Edef bogosort (list): 33 while list is notsorted: shuffle(list) С. Say we replace the second blackbox function with bubble sort which has a worst case time complexity of O(n^2). What is the worst case time complexity of the combined function (“Nameless Function Version 2" in the diagram below)? Why? The same input assumptions as those in subquestion A apply. Also remember that we are analyzing the time complexity of "Nameless Function Version 2" as a whole. Nameless Function Version 2 First blackbox function Input Bubble Sort Output (List extender) D. Finally, let's look at the overall functionality. Our input is an integer list of length n. It has at least two unique values. Our output is a sorted list of length n^2. The elements of the output list are the same as that of the input list except everything is copied n times. Can we alter the insides of Nameless Function Version 2 to decrease its worst case time complexity? How? Explain your thought process. 2 3 4 M M M 30
Jun 04, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here