Click here to Skip to main content
15,887,861 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have to make a BTree that supports basic operations. More precisely, the BTree stores music like Windows Media Player does. It must be capable of Find, Delete and Insert on Title, Album, Artist and Duration. I can't realize how to do when i delete, for example, all songs from an specific Artist and then when i look for that artist, he should not appears. I need a good idea to do that, maybe a simple and good design. I am not looking for code, just ideas .... Thanks in advance.
Posted
Updated 21-Feb-13 10:58am
v3
Comments
DinoRondelly 21-Feb-13 16:50pm    
Ok what have your tried? Where are you having problems? Do you have any code that isnt working the way you thought it was? Do you need someone to build this for you cause if so your on the wrong site ...
TRK3 21-Feb-13 18:31pm    
Who told you you "have to make a BTree" ?

Is this a class assignment?

If so, then do the work.

If not, then why a BTree? It's not my first choice for implementing the requirements you give.
leandro.castillo.valdes 22-Feb-13 10:45am    
It is my class assignment, BUT I AM NOT LOOKING FOR CODE (just ideas). I must to keep some data like this

Song
{
Title,
Artist,
Album,
Duration
}

then i do operations, basic operations on a single field.
E.g.

FindByTitle("abc");

and then returns all songs with this title (the same with artist, album and duration).
An intuitive idea is to keep FOUR BTree's, but the deletion of some title can remove
an artist, in this case i dont know how to keep all the four Btree's updated with each others,

(Example)
song1 = Song("Title1", "Jonh", "c", 180)
song2 = Song("Title2", "Jonh", "c", 200)
Songs = {song1, song2};

FindByArtist("Jonh") = { song1, song2 }
DeleteTitle("Title1")
FindByArtist("Jonh") = { song2 }
DeleteTitle("Title1")
FindByArtist("Jonh") = { }

i can't find an elegant way to do that.

DinoRondelly: Why i am in the wrong site??? There are coders here, no??
TRK3: As i said, just ideas ....

1 solution

On one side, you will keep a table of four columns, that lists all music descriptors as tuples stored in rows.

On the other side, you will maintain four B-trees that will index each of the columns. The records associated with the keys will contain row numbers in the table.

When you insert a row, be sure to update all four search indexes.

When you delete a row, be sure to delete all four fields in all four search indexes, making sure to refer to the same row every time.

To avoid wasting space in the table due to deletions, you can arrange the deleted rows as a linked list in the table, so that any new row can overwrite a deleted one.

Hope you will understand my overly concise description ;)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900