Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7785185
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:12:55+00:00 2026-06-01T20:12:55+00:00

I’ve already put a lot of work into this problem and am really near

  • 0

I’ve already put a lot of work into this problem and am really near the tail end. The overall goal was to create min length word ladders between two five letter words where each ‘rung’ of the ladder is one letter different from the previous word. For example:

[heads, heals, hells, halls, hails, tails]

The program starts where you must input a beginning and end word and the length of the ladder you want, and the program must solve it. I’ve gotten pretty far already, so I’ll spare much of the details to explain my current situation.

Say I’m going from “babes” to “child” and I’m looking for a 10 letter word ladder.

I have many thousand pairs of words, where the two pairs are one letter different from eachother. Here is just a small sample of some of the pairs.

[(bares, babes), (banes, babes), (bates, babes), (babel, babes), (bases, babes), (bales, babes)...] etc.

This goes on for a long time, but it is guaranteed in there that my destination word exists, and that there is a path between my starting word (babes) and my ending word (child) is in there, and that ladder is 10 words long.

How do I accomplish this?

EDIT: I have already implemented a graph, and am using BFS to go from the starting to ending word, which works.

public List<T> minLengthPath(T src, T dest, int length) 
{
    T start = src;

    Deque<T> queue = new LinkedList<T>();                       //Holds items to visit
    Queue<List<T>> ladder = new LinkedList<List<T>>();      //Holds all the ladders?
    Set<T> checker = new HashSet<T>();                          //Holds visited items

    queue.add(start);
    checker.add(start);

    while(!queue.isEmpty()){
        T slot = queue.remove();
        if(slot.equals(dest)) 
        { 
            System.out.println(slot);
            return null;  //Should be returning ladder
        }
        Set<Pair<Integer, T>> thing = this.edges.get(slot);
        Set<T> edges = findEdges(thing);     //Returns the edges of the node

        Iterator<T> check = edges.iterator();
        for(int a = 0; a < edges.size(); a ++) 
        {
            T hole = check.next();
            if(!checker.contains(hole))
            {
                checker.add(hole);
                queue.add(hole);
            }
        }           
    }
    return null;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:12:56+00:00Added an answer on June 1, 2026 at 8:12 pm

    Well, You are describing a graph problem which is known as the shortest path problem.

    In here, your graph is G = (V,E), where V = { all words} and E = {(u,v) | there is a direct "ladder" from word u to word v}.

    In this case, the graph is unweighted, so you can use a BFS to find the shortest path from the source to the target.

    One can also use A* algorithm for it, after finding an admissible heuristic function that evaluates how far are you from the target node. As noted by @trutheality, one possible heuristic function is the number of mismatched letters.

    Note that you don’t actually need to “create” the whole graph before you start the search, you can generate it “on the fly” using a function: next(w) = { u | (w,u) is in E, or in other words - there is a direct ladder from w to u }

    After finding what is the length of the shortest path by running a BFS, you can also find what exactly the path was – by going back. This thread explains this issue with more details. The idea is maintaining a Map – where the key is the vertex, and the value is how this vertex was discovered – the vertex that led to discovering the key. After the BFS is done, you only need to go from the target back to the source, and you got your path! [reversed, of course…]

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am currently running into a problem where an element is coming back from
For some reason, after submitting a string like this Jack’s Spindle from a text
Basically, what I'm trying to create is a page of div tags, each has
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.