A Binary Search Tree (BST) is a binary tree in which: every node has an id and a
ID: 3713890 • Letter: A
Question
A Binary Search Tree (BST) is a binary tree in which: every node has an id and a value 10 child of the node) - the value of every node is higher than the value of its left child (if present) and smaller than the value of its right child (if present).6 6 14 The figure on the right (from Wikipedia) shows a BST, where the numbers shown are the values of the nodes. 4 7 (13 (1) (1 mark) Consider the following relational schema: node(id int, value int, left int, right int, PRIMARY KEY (id)); Show an instance of the schema corresponding to the BST above.Explanation / Answer
Since,here there is no specification given for ID of node so,we can take any sequence of number as long as it is unique so that it satisfies the PRIMARY KEY constraints.
Lets take ID's from 1 to 15 in accordance with the maximum number of nodes a BST of height 3 can have i.e 15 nodes at max.
Node
Id value left right 1 8 3 10 2 3 1 6 3 10 NULL 14 4 1 NULL NULL 5 6 4 7 7 14 13 NULL 10 4 NULL NULL 11 7 NULL NULL 14 13 NULL NULLRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.