Solved

Linking Linked List To Hard Disk

Posted on 2006-07-19
7
397 Views
Last Modified: 2008-03-06
A simple linked list--

struct node{
int data;
node *next;
}


Generally when we create LL it gets created in RAM , what if I want to store it hard disk so that I can add / delete more nodes to it.



0
Comment
Question by:sinha_anshul26
  • 3
  • 3
7 Comments
 
LVL 2

Assisted Solution

by:sin_
sin_ earned 30 total points
Comment Utility
Anshu,

Since it doesn't make any sense to store the pointers in the hard disk, you can store the data of the linked list into the hard disk by writing method like:

void makePersistent(NODE* root)
{
   // get each element and store the values in some file.
}

NODE* getPersistentList()
{
   //Read from the file.
   //create the link list and associated next ptrs.
   //return it.
}

The bottom line is, you store the data of the linked list, not the ptrs.
0
 

Author Comment

by:sinha_anshul26
Comment Utility
Hi Sin_
Just to confirm I got it right...
you  mean to say,(In other words) that there is no way that we can store data at a specific location of the Hard disk (using pointers)?

I read somewhere that OS does this to manage files using FAT file system
0
 
LVL 8

Accepted Solution

by:
manish_regmi earned 20 total points
Comment Utility
In Fat it is not pointers of address but the pointers of block.

for eg. if a file occupies four blocks in block 3 5 6 9,

fat 3 points to 5 points to 6 points to 9.
it means a 32 bit fat value has block number 5.

No there is no way you can store pointers in disk. In virtual memory system you get different address each time you run (esp in dynamically allocated memory).

regards
Manish Regmi
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 2

Expert Comment

by:sin_
Comment Utility
That's right Anshu! Compiler generates the virtual memory addresses, which  are mapped to a physical page address by MMU while running the application. Therefore, everytime you run the application, you will find that your pointer is pointing to a different address.

Just imagine if you store this address; it may be a garbage next time. Persistence mechanism works by storing the content; you can reconstruct the data structure while reading it back.

Hope it helps.

0
 

Author Comment

by:sinha_anshul26
Comment Utility
>>Hope it helps
It Helped alot ...thank you both of you
0
 

Author Comment

by:sinha_anshul26
Comment Utility
Oh !! I choose the other way round sin_ 's  answer should be  Accepted and manish's assisted.
But any way thank you both for  helping


0
 
LVL 2

Expert Comment

by:sin_
Comment Utility
Not a problem! I too didn't know anything about FAT ptrs :)

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

IntroductionThis article is the second in a three part article series on the Visual Studio 2008 Debugger.  It provides tips in setting and using breakpoints. If not familiar with this debugger, you can find a basic introduction in the EE article loc…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now