Simple code for Breadth First Search Java
I have an ArrayList of arrays like this: [11, 3] [2, 3] [0, 3] [1, 4] [5, 4] [5, 7] [6, 7] [7, 8] [8, 9] [9, 10] [0, 5] I have to implement the breadth first and go from 0 to 1 by via and print all the values by putting them into a separate array. result should be: [0 5 4 1] Please someone help me out here. Where to start, and what to do?
Make a simple start to this problem. It looks like you do not understand the general idea of what is going on so lets break it down into steps. Graph your "tree". Use your first set of points to draw what the tree (or maze) looks like. You should clearly see the path from 0-5-4-1. Look into how to do a Breadth-First search. The general pattern is to start at the root and look outwards. I recommend some reading on how to do this properly in theory (https://en.wikipedia.org/wiki/Breadth-first_search). *Hint (since I am guessing this is homework): If you run it on that set of data, the first few nodes searched should be 0, 3, 4, 2, 11, 4, 7...* Lastly, implement it in Java. There is a number of questions already and tutorials online about how to achieve this. My recommendation is look at some of the related content on this website of look it up online. Unfortunately if you want to continue using the array you have been given (not recommended) it will be a fairly ineffective search. However, here is some pseudo code to get you started. bfs(starting position) for each element in the array find all elements related (connected) to starting position if(connectedNode = endNode) end search else recursively call this function on the elements found
Parse array of objects as array of String using Gson
i am getting NullPoinrException java ( code inside) [duplicate]
Thread.this cannot be referenced from static context" error
How do I modify VirtualDisplay returned by DisplayManager.createVirtualDisplay() method?
Json Object as it is use to an other method outside from AsyncTask Class
android-How to create/copy an xml file from an existing xml file in res/xml
How do I find all Java objects (not classes) with a particular annotation?
“UNAVAILABLE” gRPC failure from android client to python server
Send a file to the server via Spring Security and secure the CSRF
LibGdx Box2d collison not matching up with sprite
Call methods only ONCE per iteration
How to double the number of Days to given Date?
BLE android multiple sensors
Is it possible to execute a runnable JAR and have it run as part of the same process from which it was called?
Matching JAVA SHA-512 to Salesforce's Crypto Generated Digest
Java switch statement about number