Uniform Cost Search is an algorithm best known for its searching techniques as it does not involve the usage of heuristics. It is capable of solving any general graph for its optimal cost. Uniform Cost Search as it sounds searches in branches that are more or less the same in cost.
The algorithm uses the priority queue. This can be shown as follows:
- Insert the root into the queue
- While the queue is not empty
- Dequeue the maximum priority element from the queue
- (If the priorities are same in the queue then the alphabetically smaller path is chosen)
- If the path ends at the goal state then print the path and exit
- Else
- Insert all the children of the dequeued element, with the cumulative costs as a priority
If you are looking to learn more about a uniform-cost search algorithm then you visit this Java Tutorial. Also, if you are appearing for job profiles of Java Developer or Java Expert then you can prepare for the interviews on Java Interview Questions.