Tracks
/
C#
C#
/
Exercises
/
Simple Linked List
Simple Linked List

Simple Linked List

Medium

Introduction

You work for a music streaming company.

You've been tasked with creating a playlist feature for your music player application.

Instructions

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.

Note

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.

This exercise requires you to create a linked list data structure which can be iterated.

  1. Implement the Count property - it should not be possible to change its value from the outside
  2. Implement the Push(T value) method that adds a value to the list at its head.
  3. Implement the Pop() method which removes and returns a value from the head.
  4. Add a constructor to allow initialisation with a single value, or with an interable
  5. Implement the IEnumerable<T> interface. For more information, see this page.
  6. Ensure Reverse() method is available.
Edit via GitHub The link opens in a new window or tab
C# Exercism

Ready to start Simple Linked List?

Sign up to Exercism to learn and master C# with 62 concepts, 167 exercises, and real human mentoring, all for free.