Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need Solution Lab 6, 7 Trees, Binary search trees Lab 6 Task 1 We define the following class Node claw Nodes int datas Node

I need Solution image text in transcribed
image text in transcribed
image text in transcribed
Lab 6, 7 Trees, Binary search trees Lab 6 Task 1 We define the following class Node claw Nodes int datas Node Ieft; Node right: public Node(int data)f thisdate=data; left = mall; right = null: l public String toString off relurn data +" " i. Task 2 Define the class BSI public class Bat ? Node root: public Batu ! root - null: 1. Task 3 Complete the iterative implenentatice below to insert a key in a BST: puhlic void insertiat ay i Node n = new Node( x) : Task 4 Complete the recursive implementation below to insert a key in a BST: prikale void inserifelNode start, int ait ) public void innertectint aif insertR(root, x)c Task 5 (Done) Complete the implementation below to scarch for the minimum in a BST: privale int minimuminieke neat) int m in = rood data; while (root left i null) min = root.left data; root = roct.left; i. feturn min: Task 6 (Done) Complete the implementation helow te delele an clement in a BST: private Node delete. Recarsivol Node sovit, int lasyst if (root = nall) refura root; if (koy foot data) hiruvene icfl subtree rood.left a delete Recursive(root.ief, key). clse if (key > root.data) inarerec righit sobtres rool.right - delete Recursive(root.nght, key)s clae? Us mode sondains enty ane child. if (rook.left = mull) cotuma rovtright; clse if (toot.right = nuli) return roodileft: roct,data = minimum( roct night): root.right = delete Recursive(root.right, soot data). ) retura root: I woid delete int icy? f roo4 = delehe Recursive(root, key): Lab 7 Task 7 Create the following Tree on slide 26 using the methods implemented in Lab 6. Task 8 Implement the methods inorder, preorder and postorder seen in the lecture. Task 9 Apply the methods implemented in Task 8 to the Tree and verify that you obtain the following results : Preorder Traversal: 3,13,22,19,26,54,71,33,14,11,87,8,56,9,75,28,15,10,63,36,7,6959,68,44 Inorder Traversal: 54,26,71,19,22,11,14,33,8,87,56,13,9,75,3,63,10,15,28,59,69,68 7,36,44 Postorder Traversal: 54,71,26,19,11,14,8,56,87,33,22,75,9,13,63,10,15,59,68,69,7,44

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

More Books

Students also viewed these Databases questions

Question

3. Evaluate a Web-based training site.

Answered: 1 week ago