From d48e19ae1dcbe8a48bfecbfc6ff184bf6760e18d Mon Sep 17 00:00:00 2001 From: Katrina Owen Date: Sun, 9 Apr 2023 13:36:30 +0200 Subject: [PATCH] Rework linked-list documentation (#2245) This PR is part of our project of making our Practice Exercises more consistent and human. For more context please see the following forum-thread: https://forum.exercism.org/t/new-project-making-practice-exercises-more-consistent-and-human-across-exercism/3943 The main change is to frame the exercise within the context of story. --- exercises/linked-list/description.md | 26 -------------------------- exercises/linked-list/instructions.md | 26 ++++++++++++++++++++++++++ exercises/linked-list/introduction.md | 6 ++++++ 3 files changed, 32 insertions(+), 26 deletions(-) delete mode 100644 exercises/linked-list/description.md create mode 100644 exercises/linked-list/instructions.md create mode 100644 exercises/linked-list/introduction.md diff --git a/exercises/linked-list/description.md b/exercises/linked-list/description.md deleted file mode 100644 index bd37730242..0000000000 --- a/exercises/linked-list/description.md +++ /dev/null @@ -1,26 +0,0 @@ -# Description - -Implement a doubly linked list. - -Like an array, a linked list is a simple linear data structure. -Several common data types can be implemented using linked lists, like queues, stacks, and associative arrays. - -A linked list is a collection of data elements called *nodes*. -In a *singly linked list* each node holds a value and a link to the next node. -In a *doubly linked list* each node also holds a link to the previous node. - -You will write an implementation of a doubly linked list. -Implement a Node to hold a value and pointers to the next and previous nodes. -Then implement a List which holds references to the first and last node and offers an array-like interface for adding and removing items: - -- `push` (*insert value at back*); -- `pop` (*remove value at back*); -- `shift` (*remove value at front*). -- `unshift` (*insert value at front*); - -To keep your implementation simple, the tests will not cover error conditions. -Specifically: `pop` or `shift` will never be called on an empty list. - -Read more about [linked lists on Wikipedia][linked-lists]. - -[linked-lists]: https://en.wikipedia.org/wiki/Linked_list diff --git a/exercises/linked-list/instructions.md b/exercises/linked-list/instructions.md new file mode 100644 index 0000000000..a47942d73d --- /dev/null +++ b/exercises/linked-list/instructions.md @@ -0,0 +1,26 @@ +# Instructions + +Your team has decided to use a doubly linked list to represent each train route in the schedule. +Each station along the train's route will be represented by a node in the linked list. + +You don't need to worry about arrival and departure times at the stations. +Each station will simply be represented by a number. + +Routes can be extended, adding stations to the beginning or end of a route. +They can also be shortened by removing stations from the beginning or the end of a route. + +Sometimes a station gets closed down, and in that case the station needs to be removed from the route, even if it is not at the beginning or end of the route. + +The size of a route is measured not by how far the train travels, but by how many stations it stops at. + +```exercism/note +The linked list is a fundamental data structure in computer science, often used in the implementation of other data structures. +As the name suggests, it is a list of nodes that are linked together. +It is a list of "nodes", where each node links to its neighbor or neighbors. +In a **singly linked list** each node links only to the node that follows it. +In a **doubly linked list** each node links to both the node that comes before, as well as the node that comes after. + +If you want to dig deeper into linked lists, check out [this article][intro-linked-list] that explains it using nice drawings. + +[intro-linked-list]: https://medium.com/basecs/whats-a-linked-list-anyway-part-1-d8b7e6508b9d +``` diff --git a/exercises/linked-list/introduction.md b/exercises/linked-list/introduction.md new file mode 100644 index 0000000000..6e83ae7b6e --- /dev/null +++ b/exercises/linked-list/introduction.md @@ -0,0 +1,6 @@ +# Introduction + +You are working on a project to develop a train scheduling system for a busy railway network. + +You've been asked to develop a prototype for the train routes in the scheduling system. +Each route consists of a sequence of train stations that a given train stops at.