2 Decision Tree Models (40 points) In class, we have used the decision tree mode
ID: 3592102 • Letter: 2
Question
2 Decision Tree Models (40 points) In class, we have used the decision tree model to derive a lower bound for the worst-case running time of comparison-based sorting, including insertion sort, merge sort, heapsort and quicksort. 2.1 Mergesort (10 points) a, aal, where a, a2. Draw the decision tree model for Mergesort Given an input sequence with 2 elements: running on this sequence. 2.2 Heapsort (10 points) Given an input sequence with 8 elements: [a1, a2, a3M4, as, a6,G7, a8], where all the elements are distinct from each other. For the decision tree model for Heapsort running on this input sequence, what is the root node of your decision tree model? 2.3 Insertionsort (1O points) Given an input sequence with 8 elements: [a1,a2, a3, a4, a5, ae, a7, as], where all the elements are distinct from each other. For the decision tree model for Insertionsort running on this input sequence, what is the root node of your decision tree model? 2.4 Quicksort (10 points) Given an input sequence with 8 elements: [ai, a2, a3, a4, a5, a6, a7, a8], where all the elements are distinct from each other. For the decision tree model for Quicksort running on this input sequence, what is the root node of your decision tree model?Explanation / Answer
import turtle def irma_setup(): """Creates the Turtle and the Screen with the map background and coordinate system set to match latitude and longitude. :return: a tuple containing the Turtle and the Screen DO NOT CHANGE THE CODE IN THIS FUNCTION! """ import tkinter turtle.setup(1025, 600) # set size of window to size of map wn = turtle.Screen() wn.title("Hurricane Irma") # kludge to get the map shown as a background image, # since wn.bgpic does not allow you to position the image canvas = wn.getcanvas() turtle.setworldcoordinates(-110, 0, 0, 50) # set the coordinate system to match lat/long map_bg_img = tkinter.PhotoImage(file="atlantic-hurricane-tracking-map.gif") # additional kludge for positioning the background image # when setworldcoordinates is used # for some reason I have to move it 15 less than than 1025 width canvas.create_image(-1010, -600, anchor=tkinter.NW, image=map_bg_img) t = turtle.Turtle() wn.register_shape("hurricane.gif") t.shape("hurricane.gif") return (t, wn, map_bg_img) def irma(): """Animates the path of hurricane Irma """ (t, wn, map_bg_img) = irma_setup() # your code to animate Irma goes here # BEFORE the call to wn.exitonclick() wn.exitonclick() if __name__ == "__main__": irma() import turtle def irma_setup(): """Creates the Turtle and the Screen with the map background and coordinate system set to match latitude and longitude. :return: a tuple containing the Turtle and the Screen DO NOT CHANGE THE CODE IN THIS FUNCTION! """ import tkinter turtle.setup(1025, 600) # set size of window to size of map wn = turtle.Screen() wn.title("Hurricane Irma") # kludge to get the map shown as a background image, # since wn.bgpic does not allow you to position the image canvas = wn.getcanvas() turtle.setworldcoordinates(-110, 0, 0, 50) # set the coordinate system to match lat/long map_bg_img = tkinter.PhotoImage(file="atlantic-hurricane-tracking-map.gif") # additional kludge for positioning the background image # when setworldcoordinates is used # for some reason I have to move it 15 less than than 1025 width canvas.create_image(-1010, -600, anchor=tkinter.NW, image=map_bg_img) t = turtle.Turtle() wn.register_shape("hurricane.gif") t.shape("hurricane.gif") return (t, wn, map_bg_img) def irma(): """Animates the path of hurricane Irma """ (t, wn, map_bg_img) = irma_setup() # your code to animate Irma goes here # BEFORE the call to wn.exitonclick() wn.exitonclick() if __name__ == "__main__": irma()
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.