Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linked lists #50

Closed
wants to merge 2 commits into from
Closed

Linked lists #50

wants to merge 2 commits into from

Conversation

rohansingh9001
Copy link

Added linked-lists.py in linear-data-structures
Contains a Doubly Linked List

References to other Issues or PRs or Relevant literature

Partially Fixes issue #49 which requests to add linked lists.
Only Doubly Linked List Added so far Single Linked List Remains

Brief description of what is fixed or changed

API for the additions are as follows -

API for Double Linked List:

1)A Doubly linked list should be initialised with `DoubleLinkedList()`

2)Elements can be pushed at the start of the list using `.appendleft(data)`

3)Elements can be appended at the end using `.appendright(data)`

4) can be popped from the list at a certain index by `.pop(index)`

5)`__getitem__` and `__setitem__` support using python syntax,
eg -
`list[1]`
`list[5] =4`

6)Print the Linked List in List form using `print()` function
eg -
if elements in linked list named `sample_list` are 1-2-3-4
`>>>print(sample_list)`
`[1,2,3,4]`

7)Return length of the Linked List using `len()` function.

8)`.popright()` and `.popleft()` pops items from the right and the left respectively.

9)`.insertAt(index, data)` inserts a new Node at the index.

10)`.insertBefore(Node, data)` and `.insertAfter(Node, data)` inserts a new Node before and after the input Node respectively.

Other comments

@rohansingh9001
Copy link
Author

Work for Single Linked List is in progress.

@codecov
Copy link

codecov bot commented Dec 17, 2019

Codecov Report

Merging #50 into master will decrease coverage by 9.248%.
The diff coverage is 17.482%.

@@              Coverage Diff              @@
##            master       #50       +/-   ##
=============================================
- Coverage   98.003%   88.755%   -9.249%     
=============================================
  Files           17        18        +1     
  Lines         1102      1245      +143     
=============================================
+ Hits          1080      1105       +25     
- Misses          22       140      +118
Impacted Files Coverage Δ
...ructs/linear_data_structures/tests/linked_lists.py 17.482% <17.482%> (ø)

Impacted file tree graph

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant