0
What did I do wrong in DictionBin.translate(B)? No translation is happening. I’m getting “No comprehendo”
In the class DictionBin, the method translateB uses a binary search to search for a string in the dictionary. If found, the associated data value is returned, otherwise the string “No Comprehendo” is returned. DictionBin extends DictionBase. In DictionBase, the value returned from getKey is the english word at the position and the value returned from getVal is the spanish word at the position. https://code.sololearn.com/cu8xmK6VQOm7/?ref=app
9 Antworten
+ 2
I guess you are not performing a binary search on a 2d array, but on a 1d subdimension of a multidimensional array?
In that case you do your ordinary binary search. It requires the keys to be sorted, of course.
+ 1
getVal() is wrong, it looks at first word in dict. only
// String val = dictionArr[0][key1];
String val = dictionArr[key1][1];
+ 1
try
find test.txt manually and look inside or
add some print command to display dictionary or
BlueJ has debbuger
look at main(), this is in tutorial:
9.3 Calling main and other static methods
Summary: Static methods can be called from the class's popup menu.
Open the hello project from the examples directory. The only class in the project (class
Hello) defines a standard main method.
Right-click on the class, and you will see that the class menu includes not only the
class’s constructor, but also the static main method. You can now call main directly
from this menu (without first creating an object).
or how you add parameters for execute translate search method ?
0
Ani Jona 🕊 I added the code for the binary search but when I run it, no translation is happening. I’m getting “No comprehendo”
0
Ani Jona 🕊 I’m also getting the same thing for
https://sololearn.com/discuss/3099906/?ref=app
0
zemiak thank you. I fixed that. However, I’m still getting no comprehende. Could you please take a look at my translate method and let me know if something is incorrect?
0
it works for me, check input, if array is sorted and how you call search method
0
zemiak its a bluej program. So all I do is select the dictionary and perform translation using a test.txt file as input. So, i think something is wrong with the code I wrote but I just don’t know what it is. Sigh
0
X bx