2 Replies - 1896 Views - Last Post: 14 September 2010 - 09:47 PM Rate Topic: -----

#1 grigorianvlad  Icon User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 7
  • Joined: 14-September 10

What is the best way to implement linked list of numbers?

Posted 14 September 2010 - 08:02 PM

I am new to C++ so please go easy on the technical jargon. Have a question about linked list - or may be there is a better way to do this.
Here is the idea and I have no idea on how to implement it. Suppose we have a large file with numbers that are entered by users which are mostly repetitive (the numbers, not the users!) Something like this:
12345612345612345678
12345612345612345679
12345612345612345680
12345612345612345681
etc.
Suppose this file is in gigabytes. What I want to do is to take each entered number, decompose it to individual digits, link them somehow, create pointers in memory to their position within the line and then write only the different (new) combination of numbers and their positions.
I realize it would be easier to write the numbers as they are if this was a small amount of data. But what I am trying to do is to speed up writing and reading speed and decrease the space usage.
Questions:
1) What is the best way to do this? Linked lists and memory pointers? Examples?
2) Will space and storage difference be positive?
Thanks a lot!

Is This A Good Question/Topic? 0
  • +

Replies To: What is the best way to implement linked list of numbers?

#2 crzytrane  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 3
  • Joined: 04-September 10

Re: What is the best way to implement linked list of numbers?

Posted 14 September 2010 - 09:47 PM

How often are the users values changed? If they aren't changed that often you could take a look at data compression. If they are changed quite a bit this might not work to well because you would have to uncompress and then recompress it after, you could make a database saying eg. these 100 users numbers are in this zip file and these 100 are in this file, although this might take a bit more space up, it should save read times because of it not having to load a 1GB file each time . You could also try keep the active users together in one group and keep there file loaded ready to use. Hope this helped or at least made sense
Was This Post Helpful? 0
  • +
  • -

#3 buffalobill  Icon User is offline

  • D.I.C Head

Reputation: 21
  • View blog
  • Posts: 188
  • Joined: 08-July 08

Re: What is the best way to implement linked list of numbers?

Posted 14 September 2010 - 09:47 PM

Find the common part of all the numbers which is contiguous from the most significant digit and store as a variable. Enter the remainder of each number in to an array and sort it. The original number could be broken more that once so being saved into more than one variable.
Reconstitute each number by adding the value of each element to the variable. Print the sorted numbers.
This is so simplistic that I must have misinterpreted the problem.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1