题目
题目

FIT1008-FIT2085_S1_2025 Week 11 Workshop Quiz

多项选择题

I want to generate a balanced BST from a list with numbers from 1 to 10 inclusive and apply no self-balancing. To do that, what order should I insert items in?

选项
A.a. 5, 2, 1, 4, 3, 8, 6, 7, 9, 10
B.b. 5, 1, 2, 4, 3, 8, 6, 7, 9, 10
C.c. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
D.d. 5, 2, 1, 3, 4, 8, 7, 6, 10, 9
查看解析

查看解析

标准答案
Please login to view
思路分析
We’re asked to evaluate insertion orders for 1..10 that produce a balanced binary search tree (BST) without any self-balancing mechanism. Option a. 5, 2, 1, 4, 3, 8, 6, 7, 9, 10 - Root is 5. The left subtree (5’s left) is built from 2, 1, 4, 3, forming a structure where 2 has a left child 1 and a right child 4, which itself has a left child 3. The right subtree (5’s right) is built from 8, 6, 7, 9, 10, with 8 having left 6 (which has right 7) and right 9 (which has right 10). - Check balance at each node: At node 2 (left side), the left subtree height is 1 (node 1) and the right subtree h......Login to view full explanation

登录即可查看完整答案

我们收录了全球超50000道考试原题与详细解析,现在登录,立即获得答案。

类似问题

BST_Srch3 Below is a BST  When searching for Node 78 which node is visited 4th? Note that this is a BST not an AVL tree. AVL balancing is not a concern.

CC7_03 Create a function that takes in a Binary Search Tree (BST) and a positive integer k, returning the kth largest integer value within the BST. Assume that the BST only contains integer values and that k will always be less than or equal to the total number of nodes in the tree. For this question, duplicate integers are treated as distinct entries. For instance, in a BST with values {5, 7, 7}, the second largest value would be 7—not 5. Each BST node has an integer value, a left child node, and a right child node. A node is a valid BST node only if it adheres to the BST properties: its value is strictly greater than all values of nodes in its left subtree, and less than or equal to all values of nodes in its right subtree. The children nodes are either valid BST nodes themselves or None / null. Sample input: Sample output: 17 Given the following implementation to traverse_reverse_in_order(node, k, tree_data), which test case would fail? It is guaranteed that all the other methods are correctly implemented. The input trees depicted in the DcStrings of test cases are guaranteed to be accurate.

CC7_01 Create a function that takes in a Binary Search Tree (BST) and a positive integer k, returning the kth largest integer value within the BST. Assume that the BST only contains integer values and that k will always be less than or equal to the total number of nodes in the tree. For this question, duplicate integers are treated as distinct entries. For instance, in a BST with values {5, 7, 7}, the second largest value would be 7—not 5. Each BST node has an integer value, a left child node, and a right child node. A node is a valid BST node only if it adheres to the BST properties: its value is strictly greater than all values of nodes in its left subtree, and less than or equal to all values of nodes in its right subtree. The children nodes are either valid BST nodes themselves or None / null. Sample input: Sample output: 17 Given the following implementation to traverse_reverse_in_order(node, k, tree_data), which test case would fail? It is guaranteed that all the other methods are correctly implemented. The input trees depicted in the DcStrings of test cases are guaranteed to be accurate.

BST6, BST_Srch11 Based on our Binary Search Tree search method discussions in our lectures. Below is an algorithm written for BST search. This is not an AVL Tree so balancing is not a concern. What would be the run time complexity on average of this search algorithm  written for a BST ? BSTSearch(tree, key) { cur = tree⇢root while (cur is not null) { if (key == cur⇢key) { return cur // Found } else if (key < cur⇢key) { cur = cur⇢left } else { cur = cur⇢right } } return null // Not found }  

更多留学生实用工具

加入我们,立即解锁 海量真题独家解析,让复习快人一步!