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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T04:11:49+00:00 2026-06-17T04:11:49+00:00

Currently, I am using cell C which is the size of 1 x H,

  • 0

Currently, I am using cell C which is the size of 1 x H, where H is a very huge number. This cell is mainly used to quickly store and increment some values in very sparse indices in O(1) time. For instance,

H = 10000000;
C = cell(1, H);
...
for i = 1:last

    % all values of someIndex(i) are values from 1 to H, unsorted, and contains repeating values.

    C{ someIndex(i) } = C{ someIndex(i) } + someValues(i);

end
...

Only a tiny indices in cell C will be used – I see, most of the time, about 1-10% of the whole thing. At first, the implementation is fine for smaller size database, but I am going for bigger database, which H will grow almost exponentially. Therefore, this naive implementation will no longer work.

I was also thinking of something like, instead of using cell, use arrays to store each index and value in this fashion:

Suppose we detect a new index:

IndexArray(size(IndexArray, 2) + 1) = someIndex(i);
ValueArray(size(ValueArray, 2) + 1) = someValue(i);

Suppose we detect an old index: (sure, we will need to sweep through the whole IndexArray and see whether such old index exist or not)

ValueArray( detectOldIndex(i) ) = ValueArray( detectOldIndex(i) ) + someValue(i);

However, there is also a problem with this. As more and more indices grow, sweeping through the whole IndexArray will cost more and more time. This is O(N).

Of course, for something like this, we definitely want to go with Trees, however, in Matlab, we don’t have a valid Tree structure. I could think of using nested Cells in nested Cells. But the implementation could be quite ugly.

So if I am going to do something like this in Matlab, what are my faster choices?

  • 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-17T04:11:50+00:00Added an answer on June 17, 2026 at 4:11 am

    Have you considered using Map container?

    The Map container is basically a hash table. Therefore, it should be rather efficient in mapping a small set of “active” indices over a HUGE domain.

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

Sidebar

Related Questions

Currently I'm using this expression in a cell above the column headers of a
Currently using MySQL version 5.1.6 This is my first real world build and so
I currently using android NDK to write some native code in C. I have
I have a custom table cell which contains a number of UILabels. At runtime,
I'm currently using DataGridView with combobox as its cell in windows form, and I
I have the following cell which is used for my custom column data type
I have a table view which I'm using for some settings in my app.
we used to use a farpoint grid which made this quite easy but now
Currently using the HTTPServletRequest class and specifically the .getQueryString method to retrieve an inputted
Currently using Google Analytics as a supplement to our paid tracking software, but neither

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.