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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:20:43+00:00 2026-05-13T22:20:43+00:00

Which datastructure would you use in the place of X to have efficient merges,

  • 0

Which datastructure would you use in the place of X to have efficient merges, sorts and additions as described below?

#1 Possible solution: one HashMap to X -datastructure

Having a HashMap pointing from fileID to some datastructure linking word, wordCount and wordID may be a good solution. However, I have not found a way to implement it.


I am not allowed to use Postgres or any similar tool to keep my data neutralized.
I want to have efficient merges, sorts and additions according to fileID, wordID or wordCount for the type below.


I have the type Words which has the field fileID that points to a list of words and to relating pieces of information:

The Type

class Words
===================================
fileID: int 
[list of words] : ArrayList
[list of wordCounts] : ArrayList
[list of wordIDs] : ArrayList

Example of the data in

fileID   word   wordCount   wordID
      instance1 of words
1        He     123         1111
1        llo    321         2
      instance2 of words
2        Van    213         666
2        cou    777         932

Example of needed merge

fileID     wordID                 fileID     wordID
1          2
1          3           wordID=2
2          2           ========>  1          2
2          3                      2          2 

I cannot see any usage of set-operations such as intersections here because order is needed.

Having about three HashMaps makes sorting difficult:

  1. from word to wordID in a given fileID
  2. from wordID to fileID
  3. from wordID to wordCount in a given fileID
  • 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-13T22:20:44+00:00Added an answer on May 13, 2026 at 10:20 pm

    Why don’t you use a class to store the word, word count and word id together? Then you would need a single list for each fileID. This would IMO at least simplify the operations.

    class Word {
        private String text;
        private long count;
        private long id;
        // getters, setters
    }
    
    class Words {
        private int fileID;
        private List<Word> words;
        // getters, setters
    }
    

    This would be the skeleton, which already automatically resolves your mapping 3. Then you can add the needed additional mappings to Words and/or Word.

    I don’t understand from your description, whether the same word always have the same wordID, or can it have different IDs in different files; without this I can’t move forward with the design idea. But I hope this so far helps you get over the stalemate 🙂

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

Sidebar

Related Questions

I have an arraylist which has a class datastructure. public class empRec { public
I have been working to build a complex data structure which would return a
I was asked the following Question: How would you store the data given below(which
I'm trying to decide which datastructure to use to store key-value pairs when only
I have a custom datastructure, which can be accessed in multiple ways. I want
Which would be the best data structure to use in network manager to handle
I am creating an iPhone app which I would like to have a similar
I am trying to determine which implementation of the data structure would be best
I have a JSON-like data structure (which I don't want to change) that is
I have a data structure which uses composite ids (Which I dont wish to

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.