Greedy Search implementation for the Map of Romania
hi folks!im totally new to Java / Linux and the U.S!!I have slight knowledge of c# though.Can anyone point me towards the right direction for this problem?The famous Romania map is killin me ;)
Was given only 5 days for this assignment.Pl help me with this and eventually my grades :)
Thank you for reading...
Problem: Implement a greedy search in Java, given the map of Romania.. The
goal state is Bucharest.
You are not to visit the same city twice.
Provide the search trees.
Try three initial states.
Evaluate your solutions.
Use the Romania map with Straight Line distances.
Map of Romania :: https://kirankonathala.sslpowered.com/kirankonathala.com/AI/MapOfRomania.jpg
Straight Line Distances :: https://kirankonathala.sslpowered.com/kirankonathala.com/AI/straightLineDistances.JPG
HI Guys!Pl comment on this code -- Is it a good practice to build the tree as described here??my friend provided me this.can't we avoid hashmaps?
Pl comment...
class GreedySearch
public static void main(String a[]){
HashMap stateMap = new HashMap();
ArrayList stateList = new ArrayList();// this list is used to get the city name based on the user input
State arad = new State("Arad",366);
arad.addNextState("Timisoara",329,118);
arad.addNextState("Sibiu",253,140);
arad.addNextState("Zerind",374,75);
State bucharest = new State("Bucharest",0);
bucharest.addNextState("Glurglu",77,90);
bucharest.addNextState("Urziceni",80,85);
bucharest.addNextState("Fagaras",176,211);
bucharest.addNextState("Pitesti",100,101);
State cralova = new State("Cralova",160);
cralova.addNextState("Pitesti",100,138);
cralova.addNextState("Rimnicu",193,146);
cralova.addNextState("Dobreta",242,120);
State dobreta = new State("Dobreta",242);
dobreta.addNextState("Cralova",160,120);
dobreta.addNextState("Mehadia",241,75);
State eforle = new State("Eforle",161);
eforle.addNextState("Hirsova",151,86);
State fagaras = new State("Fagaras",176);
fagaras.addNextState("Bucharest",0,211);
fagaras.addNextState("Sibiu",253,99);
State glurglu = new State("Glurglu",77);
glurglu.addNextState("Bucharest",0,90);
State hirsova = new State("Hirsova",151);
hirsova.addNextState("Urziceni",80,98);
hirsova.addNextState("Eforle",161,86);
State iasi = new State("Iasi",226);
iasi.addNextState("Vaslui",199,92);
iasi.addNextState("Neamt",234,87);
State lugoj = new State("Lugoj",244);
lugoj.addNextState("Mehadia",241,70);
lugoj.addNextState("Timisoara",329,111);
State mehadia = new State("Mehadia",241);
mehadia.addNextState("Dobreta",242,75);
mehadia.addNextState("Lugoj",244,70);
State neamt = new State("Neamt",234);
neamt.addNextState("Iasi",226,87);
State oradea = new State("Oradea",380);
oradea.addNextState("Sibiu",253,151);
oradea.addNextState("Zerind",374,71);
State pitesti = new State("Pitesti",100);
pitesti.addNextState("Bucharest",0,101);
pitesti.addNextState("Cralova",160,138);
pitesti.addNextState("Rimnicu",193,97);
State rimnicu = new State("Rimnicu",193);
rimnicu.addNextState("Sibiu",253,80);
rimnicu.addNextState("Pitesti",100,97);
rimnicu.addNextState("Cralova",160,146);
State sibiu = new State("Sibiu",253);
sibiu.addNextState("Fagaras",176,99);
sibiu.addNextState("Rimnicu",193,80);
sibiu.addNextState("Arad",366,140);
sibiu.addNextState("Oradea",380,151);
State timisoara = new State("Timisoara",329);
timisoara.addNextState("Lugoj",244,111);
timisoara.addNextState("Arad",366,118);
State urziceni = new State("Urziceni",80);
urziceni.addNextState("Bucharest",0,85);
urziceni.addNextState("Hirsova",151,98);
urziceni.addNextState("Vaslui",199,142);
State vaslui = new State("Vaslui",199);
vaslui.addNextState("Urziceni",80,142);
vaslui.addNextState("Iasi",226,92);
State zerind = new State("Zerind",374);
zerind.addNextState("Arad",366,75);
zerind.addNextState("Oradea",380,71);
stateMap.put("Arad",arad);
stateMap.put("Cralova",cralova);
stateMap.put("Dobreta",dobreta);
stateMap.put("Eforle",eforle);
stateMap.put("Fagaras",fagaras);
stateMap.put("Glurglu",glurglu);
stateMap.put("Hirsova",hirsova);
stateMap.put("Iasi",iasi);
stateMap.put("Lugoj",lugoj);
stateMap.put("Mehadia",mehadia);
stateMap.put("Neamt",neamt);
stateMap.put("Oradea",oradea);
stateMap.put("Pitesti",pitesti);
stateMap.put("Rimnicu",rimnicu);
stateMap.put("Sibiu",sibiu);
stateMap.put("Timisoara",timisoara);
stateMap.put("Urziceni",urziceni);
stateMap.put("Vaslui",vaslui);
stateMap.put("Zerind",zerind);
stateList.add("Arad");// this list is used to get the city name based on the user input
stateList.add("Cralova");
stateList.add("Dobreta");
stateList.add("Eforle");
stateList.add("Fagaras");
stateList.add("Glurglu");
stateList.add("Hirsova");
stateList.add("Iasi");
stateList.add("Lugoj");
stateList.add("Mehadia");
stateList.add("Neamt");
stateList.add("Oradea");
stateList.add("Pitesti");
stateList.add("Rimnicu");
stateList.add("Sibiu");
stateList.add("Timisoara");
stateList.add("Urziceni");
stateList.add("Vaslui");
stateList.add("Zerind");
System.out.println(" 1) Arad \n 2) Cralova\n 3) Dobreta\n 4) Eforle\n 5) Fagaras\n 6) Glurglu\n"
+" 7) Hirsova\n 8) Iasi\n 9) Lugoj\n 10) Mehadia\n 11) Neamt\n 12) Oradea\n 13) Pitesti\n"
+" 14) Rimnicu\n 15) Sibiu\n 16) Timisoara\n 17) Urziceni\n 18) Vaslui \n 19) Zerind\n ");
System.out.print("Enter the starting State: ");
Similar Messages
-
We are having a custom WebADI, containing a field (Employee Name) which is a LOV.
The LOV has ID : Person ID, Meaning : Employee name, Description : Position Name.
There are multiple records with same Employee name but different Person ID.
If I select an Employee in the LOV which has multiple records (through different IDs), I am getting an error in WebADI:
"Enter a valid EMPLOYEE_NAME.
XX is invalid. Enter a valid value for the Mapping column EMPLOYEE_NAME"
The Query for the LOV is correct and is returning correct records.
Any pointers on this issue highly appreciated.Hi,
The problem could be with HR security profile attached to the responsibility from where you are launching the spreadsheet. Check it once.
Thanks. -
Hey everyone,
I want to install windows 8 32bit on my mac pro (mid 2012). I upgraded the windows 7 I already had, but now I dont have drivers at all...
I searched drivers for the windows 8 32 bit but couldn't find any...
Any solutions guys?
Thanks a lot.
Sincerely,
ChiponnThere's been an update for OSX ML which addresses the issue for installing Windows 8 on bootcamp.
It's NOT recommended that you Upgrade.. However, the way to get the drivers is:
You'll need an external USB drive formatted as FAT for this.
1) In OSX, start the Bootcamp Assistant
2) Press Next
3) UNTICK 'Remove WIndows 7 or Later Version'
4) TICK Download the Latest Windows Support Software from Apple
5) Insert USB drive
6) Press CONTINUE
The drivers should download, and copy a WIndowsSupport folder onto the USB drive.
I did notice that Windows 8 still requires beta drivers for some aspects such as VGA (the Radio HD Card), which you can get on the AMD website.
Futhermore, why are you using Windows 8 "32" bit when you blatently have a powerful 64bit?
Anyway, hope this post helps ;-) -
How to find the search help for the parameters stmt in a report
hi
how to find the search help for the parameters stmt in a report , that is using which addition to the parameters statementI am not sure if I understood the question,but if you meant how to attach a search help to parameter for which a default search help is not available,you can do that by using addition "Matchcode Object"
Parameter: a type i matchcode object 'Search Help Name'
Search Help name should be in single quotes.
Regards,
Anubhav.
P.S: Award Points if useful. -
How to create search path for the file on the desktop..
hello experts..
I have used gui_upload module to upload the data from flatfile to the internal table, in that how can i create search path for the file selection in the selection screen, also please help me the code to update the ztable.
thanksHI
If iam not wrong you want to select a file from a location that you don't know so if this is ur problem then use the function module
F4_FILENAME
this FM helps to locate and select the desired file from the system.
Sample code that you can check is
How to get windows filename
PARAMETERS: lv_file LIKE rlgrap-filename.
Method 1
CALL FUNCTION u2019KD_GET_FILENAME_ON_F4u2019
EXPORTING
MASK = u2019,.txt,.*u2019
STATIC = u2019Xu2019
CHANGING
FILE_NAME = LV_FILE.
Method 2
CALL FUNCTION u2019F4_FILENAMEu2019
EXPORTING
program_name = syst-cprog
dynpro_number = syst-dynnr
field_name = u2019 u2019
IMPORTING
file_name = LV_FILE.
Regards
Pavan -
Creating Enhancement Implementation for the Enhancement spot in ECC 6.0
Hi All,
I have an urgent requirement of creating an Enhancement implementation for the existing Enhancement Spot in ECC 6.0 ..
I never worked on enhancement in ECC 6.0.
There is an existing enhancement spot called "ES_SAPLIQS0" in the package " IWOC". which has got three existing implementations
1. DI_ROT_SAPLIQS0
2. ISU_SAPLIQS0
3. DIMP_GENERAL_SAPLIQS0
I need to create another implementation for the same enhancement spot.. Please let me know the detailed procedure to create the enhancement implementation for the same spot..
Thanks-
Shrikant
useful answers will be rewarded.First of all find out the include program where you want to write the logic.. Click the spiral button to go to enhancement mode.. then click on Edit > Enhancement operations> Show implicit enhancement points.
This will hightlight all the enhancement points in your include program. Right click on exact enhancement point and select Enhancement Implementations --> Create,, It should give you the same Enhancement spot you are talking about. select that and write the code.. This code will be automatically appear in the same enhancement spot. You can see one more Enhancement implementation in the same Enhancement spot from the transaction code se19.
Hope my explanation is clear, if you have any doubts, send me a mail at [email protected]
All the best.
Shrikant -
How to create Search help for the field /SAPSLL/PRGEN-ATTR20V
Hi ,
I need to add a search help for the field /SAPSLL/PRGEN-ATTR20V and their is a chk table used for this field is /SAPSLL/TCOATV20.
In this table /SAPSLL/TCOATV20-ATTRV20V is a Primary key field.
How can I add search help for this field?
Any suggestions will be appreciated!
Regards,
KittuHI,
Fixed on my own..
I am closing this thread!
Thank you!
Kittu -
Search help for the "Week Select option"
Hi Experts,
My selection screen is like this:
Article: .............. to ..............
Week ............. to ...............
I am taking article EKPO-MATNR field.and week S012-SPWOC field
Now there is there search help for the S012-SPWOC field. How can I create the seach help for this fields.
Regards
Krishanhi,
try this way.
tables: ekpo, s012.
select-options:article for EKPO-MATNR,
week for S012-SPWOC.
Regards,
Shankar. -
SAP implementation for the first time
Hi,
I'm still new to SAP and need to know a few things...
Could someone help me with the answers of the following questions?
1) What happens when a company goes through an SAP implementation for the first time.
2) how the company goes into project mode to achieve success when implementing SAP.
3) Project Members and what they do:
Basis Analyst,
Project Mgr,
Security Analyst,
Functional Analysts,
Integration Manger,
Technical Manager,
ABAPers,
etc.
4) how the business gets involved to help project members get the help they need to implement SAP.
Regards,
AshodYergat wrote:
Hi,
> 1) What happens when a company goes through an SAP implementation for the first time.
>
SAP gets implemented
> 2) how the company goes into project mode to achieve success when implementing SAP.
Project mode is a state of anarchy between start and End, and being in the state for the longest period woud guarantee success....once you started, there should never be a end
> 3) Project Members and what they do:
> Basis Analyst,
Analyses basic stuff
> Project Mgr,
He wrongly projects and manages filthily
> etc.
These are the most important ones, so always have them on board
> 4) how the business gets involved to help project members get the help they need to implement SAP.
> Regards,
> Ashod
When someone kicks on the back-side and we realize that we need to get onto Project mode - make no mistake my firend, it is the Business guys. the project guys need not worry, they will get this help for free -
N73 - trouble with search function for the contact...
Hi, i just bought a N73 series phone. i noticed that N73 search function for the contact list is different from others standard. Normally, it should show the 1st contact of the 1st letter that i pressed instead of the contact contains the letter. I found difficulties to look for the contact unless i press 3 or 4 letters. is there any setting can be changed to order search function only search the contacts with the 1st letter that i pressed instead of the letter in middle of the contact?
For example:
ang on
office
when i pressed "o", the contact will search for "ang on" instead of "office" unless i press few more letters like "off".
hope to get some help from you guys.I found the same problem as this with all my S60 3rd edition phones, what I have done is in my contacts put a hyphen (-)in between the name - i.e Joe Blogs would come us under searches for J & B, so try putting Joe-Bloggs, this way, the search will only come up with all the J's in your phone book directory.
Hope this helps, DLJ
DLJ -
Hi,
I want to populate the search help for the CJ20N Transaction for the fields in the user fields tab. Can you pl tell the suitable user exit for this.
Thanks,
JoeHi,
I hope the below BADI must help for your requirement.
Definition Name - WBS_USER_FIELDS_F4
Interface Name - IF_EX_WBS_USER_FIELDS_F4
Method - AT_F4
Hope it helps.
Reward if it is useful.
Thanks,
Srinivas -
I Need a Search Tool for the Calendar on iPod touch 2G
I am trying to replace my old Tungsten E2 Palm Pilot with my iPod touch 2G -- I have my calendar and Mobile-Me set up and synced.
The one main thing that I need is a search function for the calendar on my iPod touch 2G. That would turn the touch into a serious business tool - instead of a game/music toy.
iCal has a great search function on my Macs - I want to be able to do that on the road with the touch.
I want to be able to see the date that something happened - or when I was someplace - by searching for a name on the touch calendar. Ideally, it would work like the search function on iCal.
Is there a way - or an APP- that will do that???I asked the Apple Store here in Toronto regarding the Search or Spotlight function on the iPod Touch, which is non-existent. This feature is SO useful specially when I need to look for a past or future appointment(s) or email, or info from the Address Book. Why is this feature not included in the iPod Touch software as a basic function? I used to own a Palm PDA and even at its basic version, it had a Search function. I can easily look for names, events, memos, etc. Before iPod Touch came, I hoped that a gadget such as the Palm would be available from Apple and when the iPod Touch came out, I was SOOOO glad it surpassed the features of a Palm but hoped it had the Search of Spotlight feature that is so useful on the iMac. Can you please include on your next iPod touch Software upgrade this Search or Spotlight feature?
-
Search Birthday for the businesspartner
Hello,
I have a problem and i hope anyone can help.
In the student masterdate (PIQSTM) tabpage "Related persons" Here you can search for a related person (button create the relationship).
Here you get a search window for the business partner. Here on tabpage "Advanced Search for Business Partner Using Search Enige" you can search for a BP via the Date of Birth.
When i enter a date of birth here and exicute the search i get the message:
"Input help was canceled"
How can i solve this so i can search via date of birth.
Thanks for answering.
Greetings Luaks MolenaarHi Molenaar,
The required index has to be created in the search engine in transaction SES_ADMIN.
The index was required for:
Business object = BUS1006
Object type = 1
The search engine indexes are defined for each business object and type. If the field Object Type above contains no value, then no index exists for any type of the business object. If the field Business Object above contains no value, then a cross-object search was requested.
Regards,
Sravan V -
IOS update fix for the map app
So exactly how long do users have to wait for an update fix for the map app?
The maps included with the iPhone do not cost extra and do use the existing data plan.
AT&T Navigator (GPS) does cost an extra $9.95 (or so) per month.
Most other GPS apps have no monthly fee and use the GPS and, in some cases, the data plan on your phone.
I recommend either Navigon (takes a lot of storage room but maps are stored on the iPhone) or GPS Drive (reasonable price, has great features, maps come from the data path so requires a data signal but takes much less space). -
Does Sun provide an implementation for the PolicyManager interface (OMG)
I need an interface through which I can set Policies and view the current Policy overrides. Doesn't the Java IDL provide a default implementation for the PolicyManager interface? (on the lines of what is available in VisiBroker and JacORB)
Also want to know the values that need to be set for protocol_type if I need to use IIOP and SSLIIOP profocolsIt also makes a difference whether RMI/IIOP or Java IDL is used. Considering RMI/IIOP, there is still many work to be done. See, for example, bug 6239444, which came up when testing interoperability between Sun's and IBM's ORBs. I was told by experts that this problem came up due to the ambiguity of the RMI/IIOP specification. Java IDL should work better there.
However, the discussion seems to become off-topic :-/, I am not sure that the original question was about interoperability.
Regards,
Miran
Maybe you are looking for
-
MacBook Pro 7,1 frequently freezes, force reboot needed.
Hi all, since a while, I get frequent system crashes while doing what I assume is quite light work, since HDD is not very sollicited, CPU temperature is below 75°C, and RAM has around 3GB free. I can't find any culprit, but to notice frequency is hig
-
Shortly after installing FF4.0, it rendered a local (on my hard drive) website incorrectly. One page, with frames, has more than 1000 list entries each containing a link to another page. The links suddenly become plain text after a few hundred lines
-
I plan to buy and use a MacBook Pro with Retina display and I already own and use the PS CS 5 on my PC window-based. How can I obtain a copy of CS 5 for my MacBook Pro? Message was edited by: CHARNCHAN. That is without having to buy another copy for
-
My question is this why do I want or need vlans? Here is a little info We have 9 sites [Schools] all connected by gig fiber Right now we have a flat network no vlans, 10/100 switches and all servers are centrally located Servers are Novell 6.5 run
-
Hi, I have a help.html file wihich needs to be on every page of the application. I upload it as a static file. But I don't know how to call it and from where? Can someone help me? Thanks, Helen