Skip to content

lr: reverse linked tree#136

Merged
WazedKhan merged 1 commit into
mainfrom
reverse-linked-tree
Jun 26, 2026
Merged

lr: reverse linked tree#136
WazedKhan merged 1 commit into
mainfrom
reverse-linked-tree

Conversation

@WazedKhan

@WazedKhan WazedKhan commented Jun 26, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added a linked list reversal example that builds a list, reverses it in place, and prints the result.
  • Refactor

    • Removed several older linked list demo scripts and helper routines.
    • Cleaned up duplicate linked list examples and standalone sample output code.

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Several linked-list example modules were removed, and DSA/Linked-List/reverse_linkedlist.py was added with a Node type, an in-place reversal function, a print helper, and sample output for a reversed list.

Changes

Linked List Scripts

Layer / File(s) Summary
Linked-list module removals and reversal script
DSA/Linked-List/linked_list.py, DSA/Linked-List/merge_two_list.py, DSA/Linked-List/node.py, DSA/Linked-List/remove_duplicate_from_sorted_list.py, DSA/Linked-List/reverse_linkedlist.py
The linked-list example modules are removed, and reverse_linkedlist.py adds a node type, in-place reversal, a print helper, and sample list output.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A bunny hopped through nodes so neat,
then flipped the list with tiny feet. 🐰
“Next” went left, then right, then free,
and printed carrots 1 through 3.
Hooray for tails now leading bright!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Title check ⚠️ Warning The title mentions a linked tree, but the PR is about linked-list files and adds a reverse linked list script. Rename it to something like 'reverse linked list implementation' to match the actual change.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch reverse-linked-tree

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@DSA/Linked-List/reverse_linkedlist.py`:
- Around line 7-15: The module is executing sample setup and output at import
time instead of only when run directly. Move the linked-list construction,
reversal, and printing that currently sits alongside reverse_list and
print_linked_list into a __main__ guard so importing reverse_linkedlist only
exposes the reusable functions/classes without side effects.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 24bdf914-e187-40a9-aba6-da27fa2fca52

📥 Commits

Reviewing files that changed from the base of the PR and between 9a4b210 and 434fbd7.

📒 Files selected for processing (6)
  • DSA/Linked-List/__init__.py
  • DSA/Linked-List/linked_list.py
  • DSA/Linked-List/merge_two_list.py
  • DSA/Linked-List/node.py
  • DSA/Linked-List/remove_duplicate_from_sorted_list.py
  • DSA/Linked-List/reverse_linkedlist.py
💤 Files with no reviewable changes (4)
  • DSA/Linked-List/linked_list.py
  • DSA/Linked-List/remove_duplicate_from_sorted_list.py
  • DSA/Linked-List/node.py
  • DSA/Linked-List/merge_two_list.py

Comment on lines +7 to +15
a = Node("a")
b = Node("b")
c = Node("c")
d = Node("d")

a.next = b
b.next = c
c.next = d

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Guard the sample execution behind __main__.

Importing this module currently builds data, reverses it, and prints output immediately. That makes reverse_list and print_linked_list awkward to reuse from tests or other modules.

Suggested fix
-a = Node("a")
-b = Node("b")
-c = Node("c")
-d = Node("d")
-
-a.next = b
-b.next = c
-c.next = d
+if __name__ == "__main__":
+    a = Node("a")
+    b = Node("b")
+    c = Node("c")
+    d = Node("d")
+
+    a.next = b
+    b.next = c
+    c.next = d
 ...
-current = reverse_list(a)
-print_linked_list(current)
+    current = reverse_list(a)
+    print_linked_list(current)

Also applies to: 36-37

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@DSA/Linked-List/reverse_linkedlist.py` around lines 7 - 15, The module is
executing sample setup and output at import time instead of only when run
directly. Move the linked-list construction, reversal, and printing that
currently sits alongside reverse_list and print_linked_list into a __main__
guard so importing reverse_linkedlist only exposes the reusable
functions/classes without side effects.

@WazedKhan WazedKhan merged commit 12ad8d0 into main Jun 26, 2026
3 checks passed
@WazedKhan WazedKhan deleted the reverse-linked-tree branch June 26, 2026 01:18
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