Answered step by step
Verified Expert Solution
Question
1 Approved Answer
(a) A BST for questions 2(b)-(d). (b) The BST for question 2(e). Figure 1: An empty BST for questions 2(b), 2(c), and 2(d) on left
(a) A BST for questions 2(b)-(d). (b) The BST for question 2(e). Figure 1: An empty BST for questions 2(b), 2(c), and 2(d) on left and the BST for question 2(e) on right. 2: Binary Search Trees (BSTs) (a) Insert the following items into a BST, in the following order: [11,5, 10,21,49,35,8,46]. Show the resulting tree. [6 marks] (b) Put the following items into the BST in Figure 1a [28,37,13,48,56, 9,50,62]. Is this always unique for a fixed array and a fixed BST? Justify your answer. [6 marks] (c) Mark all non-balanced nodes in the BST in Figure 1a. Justify your answer. [6 marks] (d) In the BST you got in the part (b) delete the following items, in the following order: [9,50,28] (So when deleting 50,9 is not in the tree any-more ...). Show how the BST changes in each deletion. [6 marks] (e) Consider the AVL Tree in Figure 1b. Delete the number 11 to the tree. Note that you might need to do some rotations to preserve the AVL property. [6 marks] 3: Express your answers for the following two questions in Big-Oh notation. Justify your answers. (a) Show an upper bound on the running time of the following function. [5 marks] void fnA(int[] array, int n ) \{ int counter=1; int sum = while (counter <>
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started