Probably because your test for zero length is in the wrong place. You need to test it at the beginning of each of the methods cycleSwap and reverse, since those are the places where the error can occur.
Hello. I'm modifying the code below for my project. I just need help in Address Book GUI wherein:
1. I need to add "Enter Email Address" input in Add Record Button and
2. I need to insert another button, which is "Update Record" wherein I need to Update any existing records by typing his/her name and edit the the records of it including his/her name.
When I'm trying to modify this, I usually get an error in the codes. Please help me in this code. Thanks. No SQL Database needed and I'm using Apache Netbeans in here.
i am trying develop an algorithm to solve a Travelling Salesman Problem similar case where the goal is to find the best route with the highest attractiveness score (sum of scores for all visited sites/nodes) within a fixed time frame.
to illustrate this more:
a tourist wants to visit N attraction sites in a city and he only has 8 hours to visit as many attraction sites as possible. every site has an attractiveness score and the time spent to visit it.
- site A with ID 0 has an attractiveness score of 90 and requires 10 minutes to visit it ([0, 90, 10])
- site B with ID 1 has an attractiveness score of 69 and requires 7 minutes to visit it ([1, 69, 7])
- site C with ID 2 has an attractiveness score of 72 and requires 7 minutes to visit it ([2, 72, 11])
- site D with ID 3 has an attractiveness score of 116 and requires 16 minutes to visit it ([3, 116, 16])
and so on.
Now we have a time matrix T where T[i][j] represents the necessary time to go from site i to site j. finally we consider site 0 as both the start site and the end site, i.e. the tourist starts his journey at site 0 and returns to site 0 (a hotel for instance).
so the task is to find an itinerary for the tourist to visit as many attractions as possible with a maximum sum score of attractiveness.
example of T matrix for sites A,B,C and D (it could be 50 sites):
The TSP has been solved using different algorithms or methods but i am stuck with this one as it's a little bit different in the sense that the goal is to find the maximum attractiveness score for an itinerary within a time frame, and not the shortest route.
your help is much appreciated
I thought of methods like greedy algorithm, dynamic programming used in TSP but couldn't find a way to solve this particular problem.
Hi. Is there a build-in function like in C# to scroll the child into viewport of ScrollPane?
If not, how to achieve that using setVvalue() method of ScrollPane?
I use below method to scroll, but it scrolls every control to the top of the viewport, but I want to scroll controls which are in the bottom of viewport to the bottom.
I am trying to find the path of resource using Paths like below and then copying some files at runtime. While at runtime it works perfectly fine. However while running locally for junit testing, it throws below error at the below first line while trying to get Path using URI. I am not using any zip/jar file so why I am getting the below stack trace. Am I missing something?
Path path= Paths.get(ABCD.class.resource("/").toURI());
File mockFile= new File(path+File.seperator+mockfileName);
at java.nio.file.Paths.get(Unknown Source)
The message is clear, the path it is trying to access does not exist. You need to use the debugger to find out exactly what paths it is trying to find. That is the only way to discover what causes the problem.
Q1. Write a program using methods to find whether a point (x1,y1) lies on a circle of radius 2 cm and h = 5; the equation of circle is given by 〖(x-h)〗^2+〖(y-h)〗^2=r^2 . The method returns a Booleanvalue.
write a recursive function which takes 2 input parameters. The first is an employee id and the second is another employee id. We need this function to check if the second Employee is one of the direct or indirect managers, it must returntrueif the second employee is one of the reporting line for the first employee, otherwise it will returnfalse
Emp Id int primary key,
Name varchar(50) not null,
Manager int references Employee (Emp_ld),
JobTitle int references JobTitle(JTId)
You first have to figure out who's "at the top"; then you can recurse down the "tree": That would be the "one" with NO "Manager" (everyone else MUST have one). If you have more than one without a manager, then you have a leadership problem.
"Before entering on an understanding, I have meditated for a long time, and have foreseen what might happen. It is not genius which reveals to me suddenly, secretly, what I have to say or to do in a circumstance unexpected by other people; it is reflection, it is meditation." - Napoleon I
I am new to Java but I have worked on the Microsoft product stack. Is there a "make" and/or "project" file equivalent in Java and is there such a project file that is only associated with whichever IDE I am using?