Commit Graph

3 Commits

Author SHA1 Message Date
Sherman Hui
477b2c24b8
Hacktoberfest: Update Linked List - print_reverse method (#2792)
* chore: update print_reverse helper method

Use a generator expression instead of slicing
`elements_list` to improve the space and time complexity
of `make_linked_list` to O(1) space and O(n) time
by avoiding the creation a shallow copy of `elements_list`.

* fix: add type checking and argument typing

Add argument typing to all methods in `print_reverse`

Add doctest to helper function `make_linked_list` and
basic edge case tests to `print_reverse`

* test: add `print_reverse` test

Fix doctest syntax and remove edge case tests that are covered
by typed arguments.

Add `print_reverse` test that expects the correct values are printed
out by adding a `test_print_reverse_output` helper function.

* format code

Co-authored-by: shellhub <shellhub.me@gmail.com>
2020-10-05 19:08:57 +08:00
Christian Clauss
5df8aec66c
GitHub Action formats our code with psf/black (#1569)
* GitHub Action formats our code with psf/black

@poyea Your review please.

* fixup! Format Python code with psf/black push
2019-11-14 19:59:43 +01:00
Hanif Ali
4c37eb7d07 Improved on Singly Linked List Programs (#1558)
* Improved Singly Linked List
Added String Representations of Nodes and Linked Lists
Added support for indexing and changing of Node data using indices.

* Added a few comments to Linked Lists

* Reformatted to conform to PEP8

* Added from_sequence.py
Convert a Python List to Linked List comprising of Nodes and return head.

* Added print_reverse.py
Recursive program to print the elements of a Linked List in reverse.

* Change 'is not None' for more Pythonicness
2019-11-10 09:47:04 +01:00