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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:18:05+00:00 2026-06-13T06:18:05+00:00

Our team is working on implementation of the table widget for mobile platform (one

  • 0

Our team is working on implementation of the table widget for mobile platform (one of the application is mobile office like MS Excel).

We need to optimize the data structure for storing table data (the simple 2-d array is used).

Could you, please, suggest the optimal data structure for storing table data. Below are some of requirements for the data structure:

  • the size of the table can be up to 2^32 x 2^32;
  • majority of table cells are empty (i.e. the table is sparse), so is is desirable not to store data for empty cells;
  • interface of the data structure should support inserting/removing rows and columns;
  • data structure should allow to iterate through non-empty cells in forward and backward direction;
  • cells of the table can be merged (i.e. one cell can span more than one row and/or column).
  • 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-13T06:18:06+00:00Added an answer on June 13, 2026 at 6:18 am

    After thinking more about the problem with the row/column insertion/deletion, I’ve come up with something that looks promising.

    First, create and maintain 2 sorted data structures (e.g. search trees) containing all horizontal and all vertical indices that have at least one non-empty cell.

    For this table:

     ABCDE
    1
    2*
    3 %  #
    4
    5   $
    

    You’d have:

    1. A,B,D,E – used horizontal indices
    2. 2,3,5 – used vertical indices

    Store those A,B,D,E,2,3,5 index values inside some kind of a node in the 2 aforementioned structures such that you can link something to it knowing the node’s address in memory (again, a tree node fits perfectly).

    In each cell (non-empty) have a pair of links to the index nodes describing its location (I’m using & to denote a link/reference to a node):

    • *: &2,&A
    • %: &3,&B
    • #: &3,&E
    • $: &5,&D

    This is sufficient to define a table.

    Now, how do we handle row/column insertion? We insert the new row/column index into the respective (horizontal or vertical) index data structure and update the index values after it (=to the right or below). Then we add new cells for this new row/column (if any) and link them to the appropriate index nodes.

    For example, let’s insert a row between rows 3 and 4 and add a cell with @ in it at 4C (in the new row):

     ABCDE
    1
    2*
    3 %  #
    4  @   <- new row 4
    5      <- used to be row 4
    6   $  <- used to be row 5
    

    Your index structures are now:

    1. A,B,C(new),D,E – used horizontal indices
    2. 2,3,4(new),6(used to be 5) – used vertical indices

    The cells now link to the index nodes like this:

    • *: &2,&A – same as before
    • %: &3,&B – same as before
    • #: &3,&E – same as before
    • @: &4,&C – new cell linking to new index nodes 4 and C
    • $: &6,&D – used to be &5,&D

    But look at the $ cell. It still points to the same two physical nodes as before, it’s just that the vertical/row node now contains index 6 instead of index 5.

    If there were 100 cells nodes below the $ cell, say occupying only 5 non-empty rows, you’d need to update only 5 indices in the row/vertical index data structure, not 100.

    You can delete rows and columns in a similar fashion.

    Now, to make this all useful, you also need to be able to locate every cell by its coordinates.

    For that you can create another sorted data structure (again, possibly a search tree), where every key is a combination of the addresses of the index nodes and the value is the location of cell data (or the cell data itself).

    With that, if you want to get to cell 3B, you find the nodes for 3 and B in the index data structures, take their addresses &3 and &B, combine them into &3*232+&B and use that as a key to locate the % cell in the 3rd data structure I’ve just defined. (Note: 232 is actually 2pointer size in bits and can vary from system to system.)

    Whatever happens to other cells, the addresses &3 and &B in the %’s cell links will remain the same, even if the indices of the % cell change from 3B to something else.

    You may develop iteration on top of this easily.

    Merging should be feasible too, but I haven’t focused on it.

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

Sidebar

Related Questions

There is a team working on acceptance testing X11 GUI application in our company,
Our team working on flash/Asp.net shopping cart projects In our projects we need to
Our team is working on a new application that we started with Rails 3.1
Our team is currently working on completely redesigning our school's website and one of
In one of the projects our team is working on, we are trying to
Currently our team of 11 people is working on a project on asp.net platform.
Our team is working on Android Application back ended with App Engine. We have
One of our team is working on an ASMX service. The service use to
Our team is currently working on a large project which makes heavy use of
Our team has recently been working on a logic and data layer for our

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.