Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the node class, fill in the LookUpBST class. The LookUpBST class is on: https://pastebin.com/xVvMRH4L from lines 164-405 (a lot of lines because of the

Using the node class, fill in the LookUpBST class. The LookUpBST class is on: https://pastebin.com/xVvMRH4L from lines 164-405 (a lot of lines because of the comments)

class Node {

private T value;

private Node next;

private Node prev;

public Node(T value) {

this.value = value;

}

public T getValue() {

return value;

}

public void setValue(T value) {

this.value = value;

}

public Node getNext() {

return this.next;

}

public void setNext(Node next) {

this.next = next;

}

public Node getPrev() {

return this.prev;

}

public void setPrev(Node prev) {

this.prev = prev;

}

public static String listToString(Node head) {

StringBuilder ret = new StringBuilder();

Node current = head;

while(current != null) {

ret.append(current.value);

ret.append(" ");

current = current.getNext();

}

return ret.toString().trim();

}

public static String listToStringBackward(Node head) {

Node current = head;

while(current.getNext() != null) {

current = current.getNext();

}

StringBuilder ret = new StringBuilder();

while(current != null) {

ret.append(current.value);

ret.append(" ");

current = current.getPrev();

}

return ret.toString().trim();

}

public static void main(String[] args) {

//main method for testing, edit as much as you want

//make nodes

Node n1 = new Node<>("A");

Node n2 = new Node<>("B");

Node n3 = new Node<>("C");

//connect forward references

n1.setNext(n2);

n2.setNext(n3);

//connect backward references

n3.setPrev(n2);

n2.setPrev(n1);

//print forward and backward

System.out.println(Node.listToString(n1));

System.out.println(Node.listToStringBackward(n1));

}

}

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_2

Step: 3

blur-text-image_3

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

Advanced Database Systems For Integration Of Media And User Environments 98

Authors: Yahiko Kambayashi, Akifumi Makinouchi, Shunsuke Uemura, Katsumi Tanaka, Yoshifumi Masunaga

1st Edition

9810234368, 978-9810234362

More Books

Students also viewed these Databases questions

Question

L01 Distinguish between the processes of sensation and perception.

Answered: 1 week ago