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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:58:17+00:00 2026-06-17T05:58:17+00:00

For a class subject, I must implement a class that looks for a pattern

  • 0

For a class subject, I must implement a class that looks for a pattern in a set of chars that the class receives in a chronological order. Each character the class receives has a particular source (a planete, identified by an int ID).

We have to implement the data structure ourselves, and so I implemented a String List where I store all these characters in a chronological order.

The problem is that the pattern must be matched for characters coming from the same planete (source), so pattern matching must be made on each source.

I tried to use famous pattern matching algorithms like Rabin Karp by browsing the whole list and only taking into account the currently browsed source, and then doing this for all the sources, but the performances are really lame, even worse than a naive (but synchronous) solution.

Do you have any idea about which algorithm could be more efficient in that case ? (letting me use each character I’m browsing, even if this implies storing the actual “search state” of that source somewhere, like we did for the naive implementation)

P.S: The IDs are finite (from 1 to 128) but the number of chars can go up to 10⁷

EDIT: Here are some details that will hopefully clarify things.

IntlFinder, my class,can receive characters (or array of characters) by a method Add(char* pszData, int nSource); Hence, each character is coupled with a Source ID. The pair (character, source) is stored in a StringList ComList (in chronological order of their addition).

For the pattern to be present in my class, it must be present for THE SAME SOURCE.

Example:

If I’m looking for the pattern SAYKOUK

(S, 1); (A, 1); (Y, 1); (K, 1); (Z, 2); (S, 3); (O, 1); (U, 1); (K, 1)
is OK !

(S, 1); (A, 1); (Y, 1); (K, 2); (O, 3); (U, 1); (K, 4)
is not OK.

This is problametic because if I only consider one source (ranging from 1 to 128) and browse the whole list each time, my pattern searching method is REALLY slow. And I can’t manage with any of these algorithms to take into account the characters of the different sources and know whenever I met my pattern with any of them !

  • 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-17T05:58:18+00:00Added an answer on June 17, 2026 at 5:58 am

    I ended up using a linked list with the classical “next” and “previous” pointers but also “nextSource” and “previousSource” that points to the characters of the same source. That way, I was able to use classical pattern-matching algorithms.

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

Sidebar

Related Questions

I have a menu set up this way: <div id='top-navigation'> <ul> <li><a class='top-nav-button-unclicked' href='#'>SUBJECT</a></li>
By referring to article Implementing a Subject/Observer pattern with templates template <class T> class
I'm trying to write a safe Subject class from the observer pattern . I
I was reading different threads on the subject which suggested the Swing Timer class
class X { int i; public: X() { i = 0; } void set(int
In my last job interview I was asked how to implement a class which
I have class Student { public List<Degree> Degrees {get;set;} } class Degree { public
I have this situation: My ModelView: public class Subject { public int ID {
I'm using a custom JsonpResult class that I found in my searching here on
First off, I must apologize for my lack of knowledge on the subject. I'm

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.