Click here to Skip to main content
13,139,132 members (80,332 online)
Rate this:
Please Sign up or sign in to vote.
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 21-Feb-13 5:16am
Updated 21-Feb-13 10:58am
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


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


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,

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

FindByArtist("Jonh") = { song1, song2 }
FindByArtist("Jonh") = { song2 }
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

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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 ;)

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100