Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Q5 (20 points) On your scratch paper, draw the portion of the decision tree for Insertion sort on 5 elements 21, 22, 23, 24, as

image text in transcribed

Q5 (20 points) On your scratch paper, draw the portion of the decision tree for Insertion sort on 5 elements 21, 22, 23, 24, as that contains the path from the root node to the permutation . Then answer the following questions on the answer sheet. Here the 1st node on the root to leaf () path is the root node, which contains the comparison a, > az? (a) What is comparison at the 1st node on the root to leaf path? (b) What is comparison at the 3rd node on the root to leaf path? (C) What is comparison at the 5th node on the root to leaf path? (d) What is comparison at the 7th node on the root to leaf path? (e) What is comparison at the 9th node on the root to leaf path? Q6 (16 pts) This question tests your understanding of activation records as taught in class. (a) Assume that we want to apply Quicksort to sort the array A with 5 elements where the initial values of the array elements (from A[1] to A[5]) are A: 11 15 14 13 12 How many times do we push an activation record for Quicksort onto the runtime stack before the completion of the algorithm? (b) Assume that we want to apply Quicksort to sort the array A with 5 elements where the initial values of the array elements (from A[1] to A[5]) are A: 11 15 14 13 12 How many times do we push an activation record for Partition onto the runtime stack before the completion of the algorithm? (c) Assume that we want to apply Mergesort to sort the array A with 5 elements where the initial values of the array elements (from A[1] to A[5]) are A: 11 15 14 13 12 How many times do we push an activation record Mergesort onto the runtime stack before the completion of the algorithm? (d) Assume that we want to apply Mergesort to sort the array A with 5 elements where the initial values of the array elements (from A[1] to A[5]) are A: 11 15 14 13 12 How many times do we push an activation record Merge onto the runtime stack before the completion of the algorithm? Q5 (20 points) On your scratch paper, draw the portion of the decision tree for Insertion sort on 5 elements 21, 22, 23, 24, as that contains the path from the root node to the permutation . Then answer the following questions on the answer sheet. Here the 1st node on the root to leaf () path is the root node, which contains the comparison a, > az? (a) What is comparison at the 1st node on the root to leaf path? (b) What is comparison at the 3rd node on the root to leaf path? (C) What is comparison at the 5th node on the root to leaf path? (d) What is comparison at the 7th node on the root to leaf path? (e) What is comparison at the 9th node on the root to leaf path? Q6 (16 pts) This question tests your understanding of activation records as taught in class. (a) Assume that we want to apply Quicksort to sort the array A with 5 elements where the initial values of the array elements (from A[1] to A[5]) are A: 11 15 14 13 12 How many times do we push an activation record for Quicksort onto the runtime stack before the completion of the algorithm? (b) Assume that we want to apply Quicksort to sort the array A with 5 elements where the initial values of the array elements (from A[1] to A[5]) are A: 11 15 14 13 12 How many times do we push an activation record for Partition onto the runtime stack before the completion of the algorithm? (c) Assume that we want to apply Mergesort to sort the array A with 5 elements where the initial values of the array elements (from A[1] to A[5]) are A: 11 15 14 13 12 How many times do we push an activation record Mergesort onto the runtime stack before the completion of the algorithm? (d) Assume that we want to apply Mergesort to sort the array A with 5 elements where the initial values of the array elements (from A[1] to A[5]) are A: 11 15 14 13 12 How many times do we push an activation record Merge onto the runtime stack before the completion of the algorithm

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

8. Design office space to facilitate interaction between employees.

Answered: 1 week ago