You work for a music streaming company.
You've been tasked with creating a playlist feature for your music player application.
Write a prototype of the music player application.
For the prototype, each song will simply be represented by a number. Given a range of numbers (the song IDs), create a singly linked list.
Given a singly linked list, you should be able to reverse the list to play the songs in the opposite order.
The linked list is a fundamental data structure in computer science, often used in the implementation of other data structures.
The simplest kind of linked list is a singly linked list. That means that each element (or "node") contains data, along with something that points to the next node in the list.
If you want to dig deeper into linked lists, check out this article that explains it using nice drawings.
We have provided the general structure of a
List class for you.
It has the private variables
head of type
current_size of type
size_t that you can use.
Element struct was given as well, it has two variables:
data of type
next of type
You can see the details in
simple_linked_list.h. You do not have to change that file, but you can if it fits your needs.
The tests use the functions as they are supplied in
simple_linked_list.cpp, don't change their signature. You can add more functions and members if you want to.
Although the header-file includes raw pointers, you are free to chose a different implementation.
Sign up to Exercism to learn and master C++ with 60 exercises, and real human mentoring, all for free.