Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please help me to complete these Question 4 (Total 20 marks): Trees a) (2 marks). Draw a diagram of the binary search tree that would

image text in transcribed

please help me to complete these

Question 4 (Total 20 marks): Trees a) (2 marks). Draw a diagram of the binary search tree that would result from inserting the following numbers in the order that they are shown(showing all of your working): 97, 93, 5, 64, 70, 75, 3, 67, 91, 69 b) (2 marks). Redraw the tree from part (a) after deleting 64 and then 5. Explain the steps you used to delete these elements. c) (2 marks). Is the tree from part (a) an efficiently structured binary search tree? Why/Why not? d) (2 marks). Draw the 2-3-4 search tree that results from inserting the following sequence of numbers into an initially empty tree (showing all of your working) 24, 76, 79, 51, 87, 98, 86, 53, 42, 74 e) (2 marks). Convert the tree from part (d) above into a Red-Black tree. f) (10 marks). Given the partial definition of the Binary Tree and associated TreeNode classes below, write a method that searches for a key in the tree and then swaps that key for its value (without breaking the structure of the tree). Write a short test program that demonstrates this algorithm. You can add whatever methods to the Binary Tree" class that you require. class BinaryTree(): public class BinaryTree { private class TreeNode { class TreeNode(): def __init_(self, key, value): self.key = key self.value = value public int key; public int value; public TreeNode left; self.left = None self.right = None public TreeNode right; } def __init__(self): self.root = None private TreeNode root; def key_value_swap(self, key): #you need to implement this public void keyValueSwap (int value) { 1/you need to implement this } }

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

Beginning C# 5.0 Databases

Authors: Vidya Vrat Agarwal

2nd Edition

1430242604, 978-1430242604

More Books

Students also viewed these Databases questions