C++ Algorithmic thinking Searching Public New



A playlist is considered a repeating playlist if any of the songs contain a pointer to a previous song in the playlist. Otherwise, the playlist will end with the last song which points to NULL.

Implement a function isRepeatingPlaylist that, efficiently with respect to time used, returns true if a playlist is repeating or false if it is not.

For example, the following code prints "true" as both songs point to each other.

Song* first = new Song("Hello");
Song* second = new Song("Eye of the tiger");

std::cout << std::boolalpha << first->isRepeatingPlaylist();

  •   Example case: Exception
  •   If playlist repeats, last song is followed by first song: Exception
  •   If playlist repeats, starting songs can be skipped: Exception
  •   Performance test on a large playlist: Exception