This is a JSFiddle assignment and must be completed at jsfiddle.net and include
ID: 3575915 • Letter: T
Question
This is a JSFiddle assignment and must be completed at jsfiddle.net and include both the HTML and Java sections
Implement a TRIE that has both the functions AddToTRIE and CheckSpelling.
Once you have created the TRIE add the words (hard code) I, in, into, inlet, inn, inner, innate, ink. These are good words to use to test your TRIE
Create an interface that has one text box for entry and 2 buttons - Add To Dictionary and Spell Check. They should ad the word to the TRIE (feedback - word added) and check the word against the TRIE and return in the word was in or not in the dictionary.
Explanation / Answer
import java.util.Scanner;
/* category Node */
class Node
builder */
public Node()
/* creator */
public Node(int d, Node n, Node p)
/* perform to line link to next node */
public void setLinkNext(Node n)
/* perform to line link to previous node */
public void setLinkPrev(Node p)
/* Funtion to urge link to next node */
public Node getLinkNext()
come next;
}
/* perform to urge link to previous node */
public Node getLinkPrev()
come prev;
}
/* perform to line knowledge to node */
public void setData(int d)
/* perform to urge knowledge from node */
public int getData()
come data;
}
}
/* category linkedList */
class linkedList
finish ;
public int size;
/* creator */
public linkedList()
begin = null;
finish = null;
size = 0;
}
/* perform to envision if list is empty */
public mathematician isEmpty()
come begin == null;
}
/* perform to urge size of list */
public int getSize()
come size;
}
/* perform to insert component at begining */
public void insertAtStart(int val)
{
Node nptr = new Node(val, null, null);
if(start == null)
begin = nptr;
finish = start;
}
else
{
start.setLinkPrev(nptr);
nptr.setLinkNext(start);
begin = nptr;
}
size++;
}
/* perform to insert component at finish */
public void insertAtEnd(int val)
{
Node nptr = new Node(val, null, null);
if(start == null)
begin = nptr;
finish = start;
}
else
{
nptr.setLinkPrev(end);
end.setLinkNext(nptr);
finish = nptr;
}
size++;
}
/* perform to insert component at position */
public void insertAtPos(int val , int pos)
Node ptr = begin;
for (int i = 2; i <= size; i++)
ptr = ptr.getLinkNext();
}
size++ ;
}
/* perform to delete node at position */
public void deleteAtPos(int pos)
{
if (pos == 1)
{
if (size == 1)
begin = null;
finish = null;
size = 0;
return;
}
begin = begin.getLinkNext();
start.setLinkPrev(null);
size--;
return ;
}
if (pos == size)
Node ptr = start.getLinkNext();
for (int i = 2; i <= size; i++)
ptr = ptr.getLinkNext();
}
}
/* perform to show standing of list */
public void display()
Node ptr = start;
System.out.print(start.getData()+ " <-> ");
ptr = begin.getLinkNext();
while (ptr.getLinkNext() != null)
making object of linkedList */
linkedList list = new linkedList();
System.out.println("Doubly joined List Test ");
char ch;
/* Perform list operations */
do
{
System.out.println(" Doubly joined List Operations ");
System.out.println("1. insert at begining");
System.out.println("2. insert at end");
System.out.println("3. insert at position");
System.out.println("4. delete at position");
System.out.println("5. check empty");
System.out.println("6. get size");
int selection = scan.nextInt();
switch (choice)
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.