Question: package application; import java.util.LinkedList; import java.util.List; / / Hash Table Class public class Table { int size; / / Number of vertices. LinkedList [ ]
package application;
import java.util.LinkedList;
import java.util.List;
Hash Table Class
public class Table
int size; Number of vertices.
LinkedList table; This table contains the vertices Not adjacent.
NonArgument Constructor.
public Table
Argument Constructor.
public Tableint size
this.size size; Table Size.
table new LinkedListsize; Main Table
for int i ; i size; i
tablei new LinkedList; Each Cell Vertex has a linkedList
Aim: Add the vertices inside the Main Table.
public void addVertexVertex vertex
int index hashFunctionvertexname; Where is the Vertex should store
tableindexaddvertex; Vertex not adjacent.
Search on specific vertex using its name.
public Vertex SearchAndgetVertexString name
int index hashFunctionname;
for int i ; i tableindexsize; i
if tableindexgetiname.equalsname
return tableindexgeti;
return null; This Vertex not found inside the table.
Adding the adjacent
public void addAdjacentString vertexName, Edge adjacentVertex
Vertex vertex SearchAndgetVertexvertexName;
if vertex null
vertex.addAdjacentadjacentVertex;
else
System.out.printlnThis Vertex not found!!";
Return all vertices
public LinkedList getAllVertices as copy.
return table;
Adjacent of specific Vertex.
public List getAdjacentString vertexName
Vertex vertex SearchAndgetVertexvertexName;
if vertex null
return vertex.getAdjacentEdges; From vertex class.
else
return new LinkedList;
Aim: Produce a fixed size hash value. Unique representation of the input
private int hashFunctionString name
return name.length size;
I want array of Vertex the hash table not array of linked list
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
