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

The Archive Base Latest Questions

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

In Java, what is the fastest way to search for a word or substring

  • 0

In Java, what is the fastest way to search for a word or substring in a growing list of strings?

For example, if I have a list of ten words, and I am searching that list every five minutes for an user-entered word, and that list grows by one word every minute, what would be the best data structure to store these words in?

What we are actually doing is this…upon retrieving a “keyword,” the program must search for phrases to respond with based on that keyword, but the list of phrases is constantly growing. It takes far too long to read the keyword, parse EVERY phrase, then pick a phrase. Our current algorithm is currently at n^3, which is inappropriate.

Are there data structures in Java, or sorting/searching algorithms that would help make this more efficient?

  • 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-13T20:12:07+00:00Added an answer on June 13, 2026 at 8:12 pm

    For huge, daunting search tasks, I always use Merge Sort. The fact that your list is growing every minute shouldn’t be a problem for the algorithm. You can combine this with another checker as you go to find the words you want. Actually, once you have the first list sorted, it may even make more sense to simply insert each element where it should be in the list when you receive it, rather than looking at the data only when you begin your search.

    Keeping the list sorted this way will vastly improve your performance, assuming your rate of growth isn’t incredibly high.

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

Sidebar

Related Questions

Java. I have a very small int array (4 elements). What's the fastest way
I am wondering what is the fastest, most efficient way (using JAVA) to search
This is a Java question. What is the fastest way to convert a List<?>
What's the fastest way to concatenate two Strings in Java? i.e String ccyPair =
I have been searching a lot for the fastest way to read and write
What is the fastest way to fill up a pre-allocated ByteBuffer in Java? I
I'm using GAE/Java with Objectify, and I'm trying to find the fastest way to
What would be the fastest way to list the names of files from 1000+
What's the data structure in Java that has the fastest operation for contains() ?
Using java.net, java.io, what is the fastest way to parse html from online, and

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.