Skip to content

Add practice exercise for linked list #566

Closed

Description

@vaeng

The #12in23 challenge asks to do the linked-list exercise, which is currently not implemented and should be added during the month of March.

Activity

  1. self-assigned this
    on Mar 1, 2023
  2. siebenschlaefer commented on Mar 1, 2023

    @siebenschlaefer
    Contributor

    Does the self-assignment mean you're working on it?
    Otherwise I'll give it a try.

  3. linked a pull request that will close this issueAdd linked list practice exercise #567on Mar 1, 2023
  4. vaeng commented on Mar 1, 2023

    @vaeng
    ContributorAuthor

    Does the self-assignment mean you're working on it? Otherwise I'll give it a try.

    Yes, I have started to add some basic files, but have not yet done more (the instruction are taken from the Go track). Feel free to add more.

    One of the thoughts I wanted to discuss was the split with .cpp and header files. And if we should move the "easy" exercises to "cpp-only" to nudge the students slowly to that topic on later exercises that need more organization.

  5. siebenschlaefer commented on Mar 1, 2023

    @siebenschlaefer
    Contributor

    Some notes:

    • push(), pop(), unshift(), and shift() are mandatory, delete() and count() are optional. Do we want them?
      I'd vote yes but then we need an additional markdown file that describes them, similarly to the description of the mandatory functions.
    • The tests leave it to the tracks whether delete() should return the first or last matching element (or leave it unspecified). What do we want? I'd vote first.
    • Do we want other C++-specific things? Should the linked-list class be a class template? Do we want iterators? Do we want an exception if pop() or shift() get called on an empty list? Should count() be named size()? Tracks are allowed to add/change things when its reasonable and idiomatic.

    Attached is a Python script create_tests.txt that reads the canonical-data.json (from the problem-specification repository) and prints the contents of the linked_list_test.cpp. (It ends with .txt because GitHub does not allow attaching .py files.)

  6. vaeng commented on Mar 1, 2023

    @vaeng
    ContributorAuthor

    I think delete() is pretty interesting because you have to put in some more thoughts than just dropping elements. In my opinion, it should return the first match.

    count() might be nice, but I don't think it adds a lot.

    Iterators, class templates and exceptions should depend on where the exercise is placed in the syllabus tree. We should not add all to make it not too complex. Unless we implement simple-list as well?

    Thanks for the script! That seems super handy.

  7. vaeng commented on Mar 1, 2023

    @vaeng
    ContributorAuthor

    You do make some very good points. I think we should definitely do a simple-linked-list first. The way I see it, it is intended to have elements with int-data, push, pop, size, reverse and an array conversion. That would pave the way to have the "advanced" version as class template with iterators. What do you think @siebenschlaefer?

  8. siebenschlaefer commented on Mar 1, 2023

    @siebenschlaefer
    Contributor

    I just wanted to list these considerations explicitly so that others can weigh in.
    I'm completely fine with a simple non-template LinkedList class without exceptions that has these six methods.

    From a mentoring perspective I expect the conversations to the about memory management (naked new and raw pointers versus smart pointers a non-recursive deletion), about the general approach of the implementation (first/last pointers or a dummy node), and about helper functions/DRY. At least that's my experience for the linked-list exercise on the C track.

  9. vaeng commented on Mar 1, 2023

    @vaeng
    ContributorAuthor

    That's very valuable insight. As the memory aspects with pointer management can be a bit intimidating, the related exercises should not do much else.

    But, with the memory management questions mostly answered with the simple-list, we could dive into a nice iterator solution and make them useful via templates.

  10. vaeng commented on Mar 2, 2023

    @vaeng
    ContributorAuthor

    I added a new PR for the simple-linked-list: #570

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions