User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 455,964 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,607 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 954 | Replies: 1
Reply
Join Date: Nov 2007
Posts: 11
Reputation: jbstin is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
jbstin jbstin is offline Offline
Newbie Poster

Help random access file and creating an index file

  #1  
Nov 17th, 2007
I have a problem that deals with reading a random access file and creating an index file, which is a file to hold the binary tree of the random access file. I have the index file created with SSN (key), relative address of the SSN in the random access file, and a left and right link. What I need to do is every time a node is inserted, compare the node with the root of the tree. If it's less than, find the first SSN record in the index file that has a left link set to a -1 (dummy) and set that link equal to the position of the node I just entered. If greater than, find the first SSN record in the index file that has a right link set to a -1 (dummy) and set that link equal to the position of the node I just entered. The links are the left and right child. The first one I find with a link of -1 is the parent of the node I just inserted. Does anyone have any ideas how to do the search? Thanks for any input.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: May 2006
Posts: 2,779
Reputation: WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold WaltP is a splendid one to behold 
Rep Power: 15
Solved Threads: 229
Moderator
WaltP's Avatar
WaltP WaltP is offline Offline
Posting Maven

Re: random access file and creating an index file

  #2  
Nov 17th, 2007
After you check the root, you have to check the next node. If less, move left, if greater, move right. Check that node. If less... ad nauseum... until you run into your -1. That's where the new node goes.
Age is unimportant -- except in cheese
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 9:03 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC