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

  • Home
  • SEARCH
  • 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 4017812
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T09:54:25+00:00 2026-05-20T09:54:25+00:00

I have a list of strings (a List<String> ) that can have anywhere from

  • 0

I have a list of strings (a List<String>) that can have anywhere from 1 to 6 entries. What I want to be able to do is use that list of string to do a lookup, but I want the possible lookups to be able to use any combination of 2 or more of those strings to do the lookup. I was using a Dictionary<List<String>, String> currently.

ex.
Suppose my list has the following in it: “fire”, “aero”, “thunder”, “water”, “blizzard” and I have the following entries in my dictionary:

List<String>(){"fire", "aero"}, "searing wind"
List<String>(){"fire", "aero", "thunder"} "firestorm"
List<String>(){"aero", "thunder"}, "storm"
List<String>(){"aero", "water", "blizzard"}, "snowstorm"
List<String>(){"aerora", "blizzara"}, "hailstorm"

I want the lookup to return the first 4 entries since my base list contains all the values required to look them up. I also need to be able to know what values were used to do the lookup since those values will need to be cleared from the base list later. The number of entries in the dictionary will likely be ~400

I can think of an exhaustive way to do this lookup, but because the fact that the order is going to matter when doing the lookup, it’s going to take along time to make all the permutations and look them up. I could enforce alphabetic order in the dictionary key lists, if that would help. Does anyone know of a better way to do this, or perhaps a different, more effective way to do this? I’m already using sqlite for some other stuff in this program so if thats going to give me quicker lookups I could use that.

Thanks

  • 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-20T09:54:26+00:00Added an answer on May 20, 2026 at 9:54 am

    One option you may want to explore would be to use a decision tree. The idea would be something like this. Pick some arbitrary string, then split all of your sets into two groups – groups containing that string and groups not containing that string. Then, recursively repeat this procedure on both groups and construct a tree from all of the decisions you’ve made. For example, let’s introduce a shorthand for your notation:

    A = Aero

    R = Aerora

    F = Fire

    T = Thunder

    W = Water

    B = Blizzard

    Then you could build a tree like this:

    start ──▶   A?  ── NO ──▶ R? ── YES ──▶ B? ── YES ──▶ "hailstorm"
                 │
                 └─── YES ──▶ F? ── YES ──▶ T? ── YES ──▶ "firestorm"
                              │             │
                              │             └───── NO ──▶ "searing wind"
                              │
                              └───── NO ──▶ T? ── YES ──▶ "storm"
                                            │
                                            └───── B? ── YES ──▶ "snowstorm"
    

    Once you have a tree like this, you could store your attributes as a set of strings and then look up all matches as follows. Starting from the root of the tree, look at the string indicated by the given node. If that string is contained in your set of strings, then recursively continue down the YES branch and find all matches in that part of the tree. Then, regardless of whether you looked down that branch, explore down the NO branch to get all other strings that could match your query.

    The advantage of this approach is that, assuming you have a small number of strings as keywords, the depth of the tree can be very small – at most O(k) for k keywords – and so in the best case your search will take as little as O(k) time. In the worst case, you just explore the entire tree, which takes time O(n). Moreover, using techniques from machine learning, it’s possible to construct a very good tree structure that will have a solid tradeoff between size and lookup speed.

    Hope this helps!

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

Sidebar

Related Questions

Using bash, I have a list of strings that I want to use to
I have a list of strings that can contain a letter or a string
I have a list of customers that can be sorted by anywhere from 1
I have a variable that can either contain a list of strings or a
I have a list of string values that I want add to a hashtable
Let's say I have a short list of strings, that can contain duplicates: <A,
I have a List containing a bunch of strings that can occur more than
I have sorted list of strings that I move between php and java. to
I have a list of strings that I need to pass to a process
I have a list of strings that contain banned words. What's an efficient way

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.