Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: GimmeCode Algorithms NoEffort , +
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 6:16am
Edited 21-Feb-13 11:58am
v3
Comments
DinoRondelly at 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 at 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 at 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

Rate this: bad
good
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 Wink | ;)
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 386
1 Marcin Kozub 225
2 Sergey Alexandrovich Kryukov 215
3 /\jmot 189
4 Praneet Nadkar 173
0 OriginalGriff 8,289
1 Sergey Alexandrovich Kryukov 7,407
2 DamithSL 5,624
3 Maciej Los 4,989
4 Manas Bhardwaj 4,986


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2014
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