Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Implement a BST ADT that includes the following operations and other supporting (or required) operations in Python. For each operation, print its output with the

image text in transcribed
Implement a BST ADT that includes the following operations and other supporting (or required) operations in Python. For each operation, print its output with the given data. (ke) - an item of (key, element), vw-node 1) [15] Insert(ke): Create a binary search tree by inserting the following items, (k, e), to an initial empty BST: (25.C). (35,G),(45,B). (20, P), (30.0), (5,2), (55, L). (43.F). (22,A),(6, U), (8, N), (40, R) InOrder(v): Then, Print the keys of the BST by InOrder traversal at a tree rooted at v. In the created BST in 1) 2) [10] root(): Return a root node of the tree and print its item. 3) [10] Search(k, v): Search/return a node whose key is 45 in the BST rooted at v, and print the returned item. 4) [10] Successor(v): a) Find/return a successor of a node v whose key is 8 and print its item. b) Then find/return a successor of a node with a key 35, and print its item. 5) [10] Predecessor(v): a) Find/return a predecessor of a node whose key is 20 and print its key. b) Then, find/print the predecessor of a node with a key 40, and print its item. 6) [20] removeAbove External(w): Remove an external node w and its parent node v. then reconnect v's parent with w's sibling. Remove(k): Remove (a) a node whose key is 35, then remove (b) the node with a key 5 -Implement it with removeAbove External(w). PostOrder(v): Then(c) print the keys after each removal in 6.(a & b) by PostOrder traversal. 7) [10] rangeQuery(k1, k2, v): find and print the keys in the range of [25.45). 8) [10] isExternal(y): Test whether a node v with a key 40 is an external node or not. 9) [5] isRoot(v): Test whether a node v with a key 25 is the root of BST or not. 10) [15] Implement the LCA(v, W) algorithm of Q1 and find/print the key of LCA(v, w) where a) [5] v. key = 30,w.key = 40 b) [5] v key = 6, w.key = 55 c) [5] v key = 35. w.key = 45

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

Recommended Textbook for

Database And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions