






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







public class BinarySearchTree extends BinaryTreeBasis { // inherits isEmpty(), makeEmpty(), getRootItem(), and // the use of the constructors from BinaryTreeBasis public BinarySearchTree() { …} public BinarySearchTree(KeyedItem rootItem) { … } public void insert(KeyedItem newItem) { … } public KeyedItem retrieve(Comparable searchKey) {…} public void delete(Comparable searchKey) throws TreeException {… } public String toString() { … } } public class KeyedItem { private Comparable searchKey; private Object item; public KeyedItem(Comparable key, Object value) { … } public Comparable getKey() { … } public Object getValue() { … } public String toString() { … } } public class HashTable { public final int HASH_TABLE_SIZE= 101 ; private BinarySearchTree[] table; public HashTable() { table = new BinarySearchTree[HASH_TABLE_SIZE]; } public int hashIndex(Comparable key) { return Math.abs(key.hashCode() % HASH_TABLE_SIZE); } public String toString() { String output = ""; for (int i= 0 ; i< HASH_TABLE_SIZE; i++) { if (table[i] != null) { output = output + "\n" + i + ". " + table[i].toString(); } } return output; }
pri va te in t Dijkstras(Integer source, Integer dest) {
Code Lines Algorithm 0 Procedure Dijkstra(G: weighted connected simple graph, with all weights positive, z: vertex in G) for i := 1 to n { L(
L(a) := 0 S :=
while z
u := a vertex not in S with L(u) minimal S := S
for all vertices v not in S { if L(u) + w(u,v) < L(v) then L(v) := L(u) + w(u,v) } } return L(z)
"
v # V (^) $ _____________________