By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,116 Members | 1,282 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,116 IT Pros & Developers. It's quick & easy.

I need HELP in that program!

memoman
P: 3
Can any body help me in that program ???

mail me if anybody could reach any -helpfull- thing

Write a C++ program that namely insert, delete, and search in a fixed record length file (containing a person’s name and age). Associated with the record file will be a file that stores a binary search tree index that allows for a quick search through the index. The required operations will be provided using an input file that will be specified in the command prompt. The file will have lines with the following format:

Required_Operation (tab) Name (tab) [Age]

where Required_Operation has a value of 1, 2, or 3 which corresponds to insert, delete, and search respectively.

The Name is a string with a maximum length of 20 characters.
The Age is an optional argument that is supplied only when an insert operation is required.

If the Required_Operation is an insertion or a deletion, the word “SUCSESS” (in all capital letters) is printed to STANDARD ERR.
If the Required_Operation is a search, the Age corresponding to the Name is printed to STANDARD OUT. If the search operation fails, the word “FAILED” (in all capital letters) is printed to STANDARD OUT.

The resultant record file has to be created using the mmap function and has to be able to accommodate up to exactly 32,768 records.
Associated with the record file is a bitmap file that is exactly 32,768 bits long that indicates which records are used or free. In a bitmap file, each bit corresponds to a record in the record file (bit 10 corresponds to record 10). If the bit is set to 1, then the corresponding record is used, and if the bit is 0, then the corresponding record is empty.

When inserting, use a first-fit strategy.

When deleting a record in the record file, simply set the corresponding bit in the bitmap file to 0.

Associated with the record file is a binary search tree that includes pointers to the locations in the record file corresponding to each Name. Since using the Name field would cause the index to be large and consequently inefficient, the value stored in each node of the binary tree is the Hash value of the Name (as mentioned earlier, using the SDBM Hash function is desirable).
Again use the mmap function to store the binary tree. Each node in the binary tree will include the value in the node (unsigned int), 2 pointers to the left and right children, and a pointer to the location of the record in the record file.
Like the record file, associated with binary tree file is a bitmap file that indicates which node positions are used or free. In a bitmap file,each bit corresponds to a node location in the binary tree file (bit 10 corresponds to node location 10). If the bit is set to 1, then the corresponding node location is used, and if the bit is 0, then the corresponding node location is empty. When inserting, use a first-fit strategy. When deleting a node, simply set the corresponding bit in the bitmap file to 0 and properly adjust the tree and the associated pointers.


Thanks in advance...
Attached Files
File Type: txt Program.txt (2.9 KB, 310 views)
Mar 24 '07 #1
Share this Question
Share on Google+
4 Replies


memoman
P: 3
Please, I need HELP as fast as possible.

I've a little knowledge about C++, specially when dealing with Linus platforms like cygwin, you know mmap and these stuff.

Thanks in advance
Mar 24 '07 #2

sicarie
Expert Mod 2.5K+
P: 4,677
As per our Posting Guidelines (available in the FAQ), we can't do your program for you, you need to ask a specific question about what you are having difficulty with, and we'll try to point you in the right direction, or show you proper syntax.

SO what have you tried on this? What error messages are you getting?
Mar 24 '07 #3

memoman
P: 3
As per our Posting Guidelines (available in the FAQ), we can't do your program for you, you need to ask a specific question about what you are having difficulty with, and we'll try to point you in the right direction, or show you proper syntax.

SO what have you tried on this? What error messages are you getting?

Ah I see, thanks for declaration.

But my big problem that I dunno how to start, and how to organize all this requirments in one program.
Mar 24 '07 #4

sicarie
Expert Mod 2.5K+
P: 4,677
Ah I see, thanks for declaration.

But my big problem that I dunno how to start, and how to organize all this requirments in one program.
Break them down into different programs. Do you know how the binary search tree algorithm works?

As I see it, you have a few main things to do - you have to create this index, from an input file stream, parse the line by tabs, and organize that index by struct/class or whatever.

From there, you can fill in the details as needed, but the trick is to get that overview - however works best for you. That's also part of the reason people diagram in UML, some people use the top-down method, and I (as you can see), make an outline. Class assignments go well with the outline method - you can put the big points down, and then fill in specific requirements for each main point. With the complexity of having he data, the index, and the bitmap, I would recommend UML - it's good for modeling the relationships between objects.
Mar 25 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.