Access Millions of academic & study documents

Insertion 1

Content type
User Generated
Subject
Computer Science
School
Colorado Technical University
Type
Homework
Showing Page:
1/11
Running Head: DATA STRUCTURE IN JAVA 1
DATA STRUCTURE IN JAVA
Name:
Institution:

Sign up to view the full document!

lock_open Sign Up
Showing Page:
2/11
DATA STRUCTURE IN JAVA 2
Insertion
class Node {
Node next;
String data;
public Node (String x) {
data=x;
next=null
}
}
class HashTable {
Node [] node;
int size
public HashTable (int tablesize) {
size=8;
node=new Node[size]
}
public insert (int val) {
val %=node. length
Node nodeptr=new Node(Val)
if(node[val]==null) {
node[val]=nodeptr;
} else {

Sign up to view the full document!

lock_open Sign Up
Showing Page:
3/11

Sign up to view the full document!

lock_open Sign Up
End of Preview - Want to read all 11 pages?
Access Now
Unformatted Attachment Preview
Running Head: DATA STRUCTURE IN JAVA DATA STRUCTURE IN JAVA Name: Institution: 1 DATA STRUCTURE IN JAVA 2 Insertion class Node { Node next; String data; public Node (String x) { data=x; next=null } } class HashTable { Node [] node; int size public HashTable (int tablesize) { size=8; node=new Node[size] } public insert (int val) { val %=node. length Node nodeptr=new Node(Val) if(node[val]==null) { node[val]=nodeptr; } else { DATA STRUCTURE IN JAVA 3 nodeptr. next=node[val]; node[val]=nodeptr; } } public void main (){ HashTable hashtable=new HashTable (8) hashtable. Insert(val);}} Removal class Node { Node next; String data; public Node (String x) { data=x; next=null } } class HashTable { Node [] node; int size public HashTable (int tablesize) { size=8; node=new Node[size] DATA STRUCTURE IN JAVA } public remove (int val){ val %=node.length; Node start=Node[val]; Node end=start; if(start.data==val){ node[val]=start.next; size--; return; } while(end.next!=null&&end.next.data!=val){ end=end.next; if(end.next.next==null){ end.next=null return; } end.next=end.next.next; node[val]=start; } } 4 DATA STRUCTURE IN JAVA 5 public void main (){ HashTable hashtable=new HashTable (8) hashtable. remove(val);}} Documentation We have to create the class Node, object node to form data type that would be used in the list structure (Yazdani et al., 2016). class Node { Node next; String data; public Node (int x) { //construct data=x; next=null } } Another class HashTable has t ...
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.
Studypool
4.7
Indeed
4.5
Sitejabber
4.4

Similar Documents