Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A Data file which contains records to be read into the data structure. Record.ja

ID: 3813828 • Letter: A

Question

A Data file which contains records to be read into the data structure.

Record.java: The “Record" class will be the objects stored in the value for each keyword in the tree. This class also has a "next" pointer which provides the structure for the linked list. Objects of this type will be the value of each node in your search tree. This code should not be modified.

Test.java: This code performs reading from the data file as well as allowing test operations of your binary search tree. Performing changes to this file can be done to test particular cases, but this is for your benefit, since it will not be collected. The code provided will print the contents of the tree in inorder, which is alphabetical order. At each node of the tree, it will print the key word and then the titles of all the records in the list that you have created at that node. The test code also performs a few deletions and checks the result to ensure that delete() works correctly.

bst.java This file contains the basic shell for the data structure we will ask you to implement in this assignment. All functions that you will be asked to implement are marked with a \TODO comment and are listed below with their expected operation. You will need private functions for implementing these recursively.

Node constructor: This function should initialize a record with keyword `k'. It will not require the other fields to be set because every Node construction will be updated either by directly modifying the children or by performing an update() to add a record to its linked list.

Node update(Record r): This function should add the Record r to the linked list for a particular keyword. You should add new Records to the front of the list.

insert(String keyword, FileData fd): This function includes code that turns the FileData fd into a Record recordToAdd. The function should insert recordToAdd to the node of keyword. If keyword is not in the tree, it should create a node.

contains(String keyword): This function should return true if the keyword keyword is in the tree.

get_records(String keyword): This function returns the linked list of Records associated with a given String keyword.

delete(String keyword): This function removes the node associated with the input string keyword. If no such node exists, the code should do nothing.

Explanation / Answer

#include <iostream>
#include <cstdlib>
#define MAX_VALUE 65536
using namespace std;

/* category Node */

class Node
;

/* category ThreadedBinarySearchTree */

class ThreadedBinarySearchTree
builder */
ThreadedBinarySearchTree()
  

/* perform to clear tree */
void makeEmpty()
  

/* perform to insert a key */
void insert(int key)

else if (p->key > key)
  
else
  
}
Node *tmp = new Node();
tmp->key = key;
tmp->rightThread = tmp->leftThread = true;
if (p->key < key)
facet */
tmp->right = p->right;
tmp->left = p;
p->right = tmp;
p->rightThread = false;
}
else
  
}

/* perform to look for a part */
bool search(int key)
come false;
tmp = tmp->right;
}
else if (tmp->key > key)
come false;
tmp = tmp->left;
}
else
come true;
}
}
}

/* Fuction to delete a part */
void Delete(int key)

else if (dest->key > key)
  
else
  
}
Node *target = dest;
if (!dest->rightThread && !dest->leftThread)
2 children*/
p = dest;
/* realize largest node at left kid */
target = dest->left;
whereas (!target->rightThread)
  
/* exploitation replace mode*/
dest->key = target->key;
}
if (p->key >= target->key)

else if (target->rightThread)
{
Node *largest = target->left;
whereas (!largest->rightThread)
  
largest->right = p;
p->left = target->left;
}
else
{
Node *smallest = target->right;
whereas (!smallest->leftThread)
  
smallest->left = target->left;
p->left = target->right;
}
}
else
  
else if (target->rightThread)
{
Node *largest = target->left;
whereas (!largest->rightThread)
  
largest->right = target->right;
p->right = target->left;
}
else
{
Node *smallest = target->right;
whereas (!smallest->leftThread)
  
smallest->left = p;
p->right = target->right;
}
}
}

/* perform to print tree */
void printTree()
{
Node *tmp = root, *p;
for (;;)
{
p = tmp;
tmp = tmp->right;
if (!p->rightThread)
{
whereas (!tmp->leftThread)
  
}
if (tmp == root)
break;
cout<<tmp->key<<" ";
}
cout<<endl;
}
};

/* Main Contains Menu */

int main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote