0
Can anyone assist me in writing a search algorithm for songs in a playlist designed to locate a particular song?
5 Respostas
+ 1
If the playlist is sorted, you can look for the song letter by letter (you may use binary search or any other algorithm, sololearn has courses about it, also has courses for sorting items)
If it's not sorted, you should check each item until you find the song.
0
Ok. I am new to programming so would the best way to do it be as a string?
0
An array of strings is the most basic way of doing it.
You can iterate through the array (with a loop or iterator) and compare every song name with the needed one
In C++ you could use strcmp function (included in <string.h>, use it if you use char arrays and not string objects)
Also String objects may be compared using the == operator (i'm not sure but i think it's possible)
0
Thank you so much. I'm going to try and knock this out
0
Ok, tell me if you have doubts or bugs