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 6915773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:31:01+00:00 2026-05-27T09:31:01+00:00

I know, maybe this question is stupid but I am stuck and I need

  • 0

I know, maybe this question is stupid but I am stuck and I need real help. I need in my project use algorithm that could find all words what starts by another and return all words’ tails. For example:
Find all words that start by: dad

In dictionary we have:

dada, dadaism, daddled, daddling

Result:

a, aism, dled, dling

I have dictionary with all words, so all what I need is only algorithm. Someone suggested me to use patricia algorithm but I couln’t find any sample for C#. My dictionary is very big so I need find also very fast algorithm.


More information:

  • Dictionary is sorted.
    • 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-05-27T09:31:02+00:00Added an answer on May 27, 2026 at 9:31 am

      How you make this work will depend on how your dictionary is arranged. If it’s a sorted list of words, then you can use binary search to find the first word that starts with “dad”, and then loop through just those using StartsWith and Substring. That is:

      List<string> Words = LoadWords(); // however you load them
      Words.Sort();
      
      // Now, search for "dad" (or whatever)
      string prefix = "dad";
      
      int index = Words.BinarySearch(prefix);
      
      // If the returned index is negative, the word wasn't found.
      // The index is the one's compliment of the the place where it would be in the list.
      if (index < 0)
      {
          index = ~index;
      }
      
      for (int i = index; i < Count && Words[i].StartsWith(prefix))
      {
          Console.WriteLine(Words[i].Substring(prefix.Length));
      }
      

      This should be very fast. The sort is a one-time cost after loading. And you can eliminate it altogether if you store the dictionary in sorted order. The binary search is O(log n), where n is the number of words in the dictionary.

      If your dictionary is unordered, then you’ll have to go through all the words, which is going to take a lot of time.

      There are other organizations for your dictionary, that will make it take a lot less space and that could potentially be faster. Those are somewhat more complicated and take a lot more time to build than creating a sorted list.

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

    Sidebar

    Related Questions

    Maybe this is a stupid question, but I dont know how to use Membership
    This may be a stupid question to ask, but still I need to know
    I know maybe this is a stupid question, But i suck at sql But
    I know this maybe a stupid question but maybe I'm just confused with the
    This is maybe a stupid question, but I want to know if my code
    I know that maybe this question has been asked before, but I can't seem
    Ok so this maybe a simple/silly question but I don't know so here goes:
    I know that this may be an amateur question but for some reason I
    This may be very simple question,But please help me. i wanted to know what
    I know this may be a stupid question to ask but I have really

    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.