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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:45:48+00:00 2026-06-18T01:45:48+00:00

I have been working on a practical situation wherein I require an algorithm, have

  • 0

I have been working on a practical situation wherein I require an algorithm, have made a generic problem out of that. Considering there are are Two Arrays :-

Source[10] = {‘a’, ‘v’, ‘l’, ‘r’, ‘p’, ‘s’, ‘x’, ‘d’, ‘q’, ‘o’ , ‘g’, ‘m’}

Target[N] = {‘a’, ‘v’, ‘l’, ‘r’, ‘p’, ‘s’, ‘x’, ‘d’, ‘q’, ‘o’ , ‘g’, ‘m’,a’, ‘v’, ‘l’, ‘r’, ‘p’,a’, ‘v’, ‘l’, ‘r’, ‘p’,a’,

‘v’, ‘l’, ‘r’, ‘p’,a’, ‘v’, ‘l’, ‘r’, ‘p’,a’, ‘v’, ‘l’, ‘r’, ‘p’,a’, ‘v’, ‘l’, ‘r’, ‘p’,a’, ‘v’, ‘l’, ‘r’, ‘p’,a’, ‘v’,

‘l’, ‘r’, ‘p’,a’, ‘v’, ‘l’, ‘r’, ‘p’, …. }

We need to have an efficient algorithm to find the frequency of occurrences of characters from Source in Target.

I have thought of hashing the complete Target list and then iterate through the Source and do the lookup in the hashed list. Can people comment/validate the approach.

  • 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-18T01:45:49+00:00Added an answer on June 18, 2026 at 1:45 am

    If your character set is reasonably limited, you can use character codes as indexes into an array of counts. Let’s say you have 16-bit characters. You can do this:

    int[] counts = new int[65536];
    foreach (char c in Target)
        counts[c]++;
    

    With the array of counts in hand, you can easily find the frequency by looking up a code from the Source in the counts array.

    This solution is asymptotically as fast as it could possibly get, but it may not be the most memory-efficient one.

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

Sidebar

Related Questions

I have been working with NSArray s and NSMutableArray s that store NSDate objects
I have been working on a Android Web Services program that uses a number
I've been working on a project where I have been using LinqToSQL that involved
i have been successfully working with linq2sql and the linq DTOs (the classes that
I have been working with a few applications that deal with NSURLConnections. While researching
I have been working on a list for a while that helps me share
I am working on my first large project that uses EF4 and have been
I have been working with the book Practical Ruby Gems. It gave me the
I've been working on a problem for several weeks and have reached a point
I have been working on some code that is similar to the following: typedef

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.