# Complete the get and put methods for the following Binary Search

Content type
User Generated
Rating
Showing Page:
1/6
Complete the get and put methods for the following Binary
Search Tree. You can assume that Key implements
Comparable; and Value class is given. State any
assumptions you make in your implementation. public
class BST, Value> State any assumption ou make in jour
implementation. t private Node root //Root of Binary
Search Tree private class Nodef //Key //Associated Value
private Key key: private Value val; private Node left, right:
//Links to sub trees private int N //.of nodes in subtree
rooted // here public Node (Key key, Value val, int N) t
this.key keyi this.val = val; this,N N;
Solution
Implementaion of get and put method....
import javax.xml.soap.Node;
public class BST <Key extends Comparable<Key>,Value,
K>{
private Node root;
//Root of binary search Tree
private class Node{

Sign up to view the full document!

Showing Page:
2/6
private Key key;//key
private Value val;//Associated value
private Node left,right;//link to subtree
private int N;
public Node(Key key, Value val, int n) {
super();
this.key = key;
this.val = val;
N = n;
}
public Key getKey() {
// TODO Auto-generated method stub
return null;
}
public Value getLeft() {
// TODO Auto-generated method stub
return null;
}
public Value getRight() {
// TODO Auto-generated method stub
return null;
}
public void setKey(K smallVal) {
// TODO Auto-generated method stub

Sign up to view the full document!

Showing Page:
3/6

Sign up to view the full document!

End of Preview - Want to read all 6 pages?
Access Now
Unformatted Attachment Preview
Complete the get and put methods for the following Binary Search Tree. You can assume that Key implements Comparable; and Value class is given. State any assumptions you make in your implementation. public class BST, Value> State any assumption ou make in jour implementation. t private Node root //Root of Binary Search Tree private class Nodef //Key //Associated Value private Key key: private Value val; private Node left, right: //Links to sub trees private int N //.of nodes in subtree rooted // here public Node (Key key, Value val, int N) t this.key keyi this.val = val; this,N N; Solution Implementaion of get and put method.... import javax.xml.soap.Node; public class BST { private Node root; //Root of binary search Tree private class Node{ private Key key;//key private Value val;//Associated value private Node left,right;//link to subtree private int N; public Node(Key key, Value val, int n) { super(); this.key = key; this.val = val; N = n; } public Key getKey() { // TODO Auto-generated method stub return null; } public Value getLeft() { // TODO Auto-generated method stub return null; } public Value getRight() { // TODO Auto-generated method stub return null; } public void setKey(K smallVal) { // TODO Auto-generated method stub } } //get the value paired with key public Value get(Key){ return get(root,Key); } // return value associated key in subtree rooted at X; // return null if key is not present; public Value get(Node x,Key ...
Purchase document to see full attachment
User generated content is uploaded by users for the purposes of learning and should be used following Studypool's honor code & terms of service.

### Review

Anonymous
I use Studypool every time I need help studying, and it never disappoints.

Studypool
4.7
Trustpilot
4.5
Sitejabber
4.4