u.equals(x) happens when 'u' gets through all the prevs to the room we wanted and needed to visit.
u = u.prev; is assigning the previous room to our variable 'u'.
'x' is a room we needed to...
Type: Posts; User: dezett
u.equals(x) happens when 'u' gets through all the prevs to the room we wanted and needed to visit.
u = u.prev; is assigning the previous room to our variable 'u'.
'x' is a room we needed to...
Ok, I will post the code and sorry for my absence from the topic but I had some problems.
So, this function gives the error:
public void run(Vertex x)
{
this.roomNumber = 0;
...
Well, I have found my mistake. The problem was in function Relax: I didn't add back the vertex which weight was the smallest of all. Thank you for your reply though.
//EDIT: Though now I have...
Hello once again.
I wrote a program which uses Dijkstra's algorithm to give us the best weight path through an labyrinth (though every room has 2, 3 or 4 neighbours). Each room has it's weight. We...
So: 1. I got it from a friend.
2. constant 53 is: number of small letters + big letters + space.
3. 96 is the code of "`" before "a" in the ASCII code.
4. l is the size of the dictionary.
I...
I think my hash function has some issue.
It should give me numbers 1-7 and for "g" it gives me 0.
public static int hash(String key, int l)
{
int value = 0;
for(int j =...
That's right. So in BSTs i should just compare strings? No rehash needed?
I need to use a Hashtable with an independent connecting which will store Binary Search Trees (words are to be stored in an lexicographical order).
I mean: e.g. I get a word with a hashcode 1, so i save it in the BST with the number 1. If i get another word (it's different than the 1st), but it has the same hashcode, I want to save it in the BST...
How should i rehash the words with the same hashcode? Creating another rehash method or using hash again(if hash - how?)?
I have modified the constructor. Trying to fill the array with the instances.
DHT(int n)
{
bst = new BST[n];
for(int i = 0; i < n; i++)
...
return bst[k].insert(x, k);
variables: x, k, bst array.
x = a
k = n
bst[1 - n] = null
line 236
public static class DHT
{
Well, i Can't find such a variable. Though when i was trying to debug, i found that the program has some problems with the DHT constructor. This is what it displayed: Not able to submit breakpoint...
Exception in thread "main" java.lang.NullPointerException
at JavaApplication18$DHT.insert(JavaApplication18.java:244)
at JavaApplication18.main(JavaApplication18.java:18)
The problem is clearly in the insert method of the BST/DHT class. It crashes at the beginning, while passing the variables from DHT insert to BST insert. It doesn't even print anything when I add a...
I have corrected the code. Now it has no compiler errors.
I have added to the code in main:
while(!"#".equals(s))
{
int p = hash(s, n);
System.out.println(s + " " + n...
Well, I did as you told me, but it didn't tell me a thing. When I printed the variables i didn't get any null value. They were good. I did the whole function with the arguments given on the paper and...
Hello. I have a problem with my code.
I have implemented BST Tree as well as DHT but my code doesn't work.
Here it is:
import java.util.Scanner;
public class JavaApplication18
{
...