can you help me to deaw the flow chart for the java code below: import java.util.Scanner; class DataItem { private int iData; public DataItem next; public DataItem(int i) { iData = i; } public int getKey() { return iData; } public void displayDataItem() { System.out.print(iData + " "); } } class SortedList { private DataItem first; public void SortedList() { first = null; } public void insert(DataItem dItem) { int key = dItem.getKey(); DataItem previous = null; DataItem current = first; while (current != null && key > current.getKey()) { previous = current; current = current.next; } if (previous == null) { first = dItem; } else { previous.next = dItem; } dItem.next = current; } public void delete(int key) { DataItem previous = null; DataItem current = first; while (current != null && key != current.getKey()) { previous = current; current = current.next; } if (previous == null) { first = first.next; } else { previous.next = current.next; } } public DataItem find(int key) { DataItem current = first; while (current != null && current.getKey() <= key) { if (current.getKey() == key) { return current; } current = current.next; } return null; } public void displayList(int index) { System.out.print("[" + index + "] => "); DataItem current = first; while (current != null) { current.displayDataItem(); current = current.next; } System.out.println(""); } } class HashTable { private SortedList[] hashArray; private int arraySize; public HashTable(int size) { arraySize = size; hashArray = new SortedList[arraySize]; for (int j = 0; j < arraySize; j++) { hashArray[j] = new SortedList(); } } public void displayTable() { for (int j = 0; j < arraySize; j++) { hashArray[j].displayList(j); } } public int hashFunc(int key) { return key % arraySize; } public void insert(DataItem dItem) { int key = dItem.getKey(); int hashVal = hashFunc(key); hashArray[hashVal].insert(dItem); } public void delete(int key) { int hashVal = hashFunc(key); hashArray[hashVal].delete(key); } public DataItem find(int key) { int hashVal = hashFunc(key); DataItem theLink = hashArray[hashVal].find(key); return theLink; } } class HashTableApp { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int aKey; DataItem aDataItem; int size = 100; System.out.println("##----HashTable App----##"); System.out.print("\nEnter size of hash table: "); size = aKey = scan.nextInt(); HashTable hashTableObj = new HashTable(size); boolean quit = false; while (quit == false) { System.out.println("\nEnter your choice number from the following: "); System.out.println("1. Print HashTable \n2. Insert Item \n3. Delete Item \n4. Find Item By Key \n5. Quit"); System.out.print("Your choice = "); int choice = scan.nextInt(); switch (choice) { case 1: hashTableObj.displayTable(); break; case 2: System.out.print("\nEnter key value to insert: "); aKey = scan.nextInt(); aDataItem = new DataItem(aKey); hashTableObj.insert(aDataItem); break; case 3: System.out.print("\nEnter key value to delete: "); aKey = scan.nextInt(); hashTableObj.delete(aKey); break; case 4: System.out.print("\nEnter key value to find: "); aKey = scan.nextInt(); aDataItem = hashTableObj.find(aKey); if (aDataItem != null) { System.out.println("Found " + aKey); } else { System.out.println("Could not find " + aKey); } break; case 5: quit = true; System.out.println("\nThanks for using --HashTableApp- -\n"); break; default: System.out.print("\nInvalid entry\n"); } } while (quit == false); } }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

can you help me to deaw the flow chart for the java code below:

import java.util.Scanner;
class DataItem {
private int iData;
public DataItem next;
public DataItem(int i) {
iData = i;
}
public int getKey() {
return iData;
}
public void displayDataItem() {
System.out.print(iData + &quot; &quot;);
}
}
class SortedList {
private DataItem first;
public void SortedList() {
first = null;
}
public void insert(DataItem dItem) {
int key = dItem.getKey();
DataItem previous = null;
DataItem current = first;
while (current != null &amp;&amp; key &gt; current.getKey()) {
previous = current;
current = current.next;
}
if (previous == null) {
first = dItem;
} else {

previous.next = dItem;
}
dItem.next = current;
}
public void delete(int key) {
DataItem previous = null;
DataItem current = first;
while (current != null &amp;&amp; key != current.getKey()) {
previous = current;
current = current.next;
}
if (previous == null) {
first = first.next;
} else {
previous.next = current.next;
}
}
public DataItem find(int key) {
DataItem current = first;
while (current != null &amp;&amp; current.getKey() &lt;= key) {
if (current.getKey() == key) {
return current;
}
current = current.next;
}
return null;
}
public void displayList(int index) {
System.out.print(&quot;[&quot; + index + &quot;] =&gt; &quot;);
DataItem current = first;
while (current != null) {
current.displayDataItem();
current = current.next;
}
System.out.println(&quot;&quot;);
}
}

class HashTable {
private SortedList[] hashArray;
private int arraySize;
public HashTable(int size) {
arraySize = size;
hashArray = new SortedList[arraySize];

for (int j = 0; j &lt; arraySize; j++) {
hashArray[j] = new SortedList();
}
}
public void displayTable() {
for (int j = 0; j &lt; arraySize; j++) {
hashArray[j].displayList(j);
}
}
public int hashFunc(int key) {
return key % arraySize;
}
public void insert(DataItem dItem) {
int key = dItem.getKey();
int hashVal = hashFunc(key);
hashArray[hashVal].insert(dItem);
}
public void delete(int key) {
int hashVal = hashFunc(key);
hashArray[hashVal].delete(key);
}
public DataItem find(int key) {
int hashVal = hashFunc(key);
DataItem theLink = hashArray[hashVal].find(key);
return theLink;
}
}
class HashTableApp {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
int aKey;
DataItem aDataItem;
int size = 100;
System.out.println(&quot;##----HashTable App----##&quot;);
System.out.print(&quot;\nEnter size of hash table: &quot;);
size = aKey = scan.nextInt();
HashTable hashTableObj = new HashTable(size);
boolean quit = false;
while (quit == false) {
System.out.println(&quot;\nEnter your choice number from the
following: &quot;);
System.out.println(&quot;1. Print HashTable \n2. Insert Item \n3.
Delete Item \n4. Find Item By Key \n5. Quit&quot;);
System.out.print(&quot;Your choice = &quot;);
int choice = scan.nextInt();
switch (choice) {

case 1:
hashTableObj.displayTable();
break;
case 2:
System.out.print(&quot;\nEnter key value to insert: &quot;);
aKey = scan.nextInt();
aDataItem = new DataItem(aKey);
hashTableObj.insert(aDataItem);
break;
case 3:
System.out.print(&quot;\nEnter key value to delete: &quot;);
aKey = scan.nextInt();
hashTableObj.delete(aKey);
break;
case 4:
System.out.print(&quot;\nEnter key value to find: &quot;);
aKey = scan.nextInt();
aDataItem = hashTableObj.find(aKey);
if (aDataItem != null) {
System.out.println(&quot;Found &quot; + aKey);
} else {
System.out.println(&quot;Could not find &quot; + aKey);
}
break;
case 5:
quit = true;
System.out.println(&quot;\nThanks for using --HashTableApp-
-\n&quot;);
break;
default:
System.out.print(&quot;\nInvalid entry\n&quot;);
}
}
while (quit == false);
}
}

Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY