Repository navigation
R23-T029: Add iterative binary tree merge and variant analysis - #120
Open
mohammedsohail0301-dot wants to merge 1 commit into
Open
mohammedsohail0301-dot wants to merge 1 commit into
mohammedsohail0301-dot wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
Task R23-T029: Iterative (stack-based) binary tree merge implementation and variant analysis
Contributed a new file
data_structures/binary_tree/merge_two_binary_trees_iterative.pyadhering to all repository standards and verified equivalence with the existing recursive version.1. Goal and Implementation
merge_two_binary_trees_iterative(tree1, tree2)using an explicit stack of pairs(Node, Node)on the heap.from __future__ import annotations,Node | None).TypeErrorwith doctest tracebacks.merge_two_binary_trees.pyin doctests and verified identical pre-order outputs:print_preorder(merged)gives9, 11, 2, 1, 15, 4.get_preorder(merged_iter) == get_preorder(merged_rec).2. Variant & Stack Depth Analysis (
work/R23-T029/VARIANT.md)sys.getrecursionlimit() = 1000; crashes on skewed trees withRecursionErrorat depth 1,200.3. Verification & Test Evidence
python3 scripts/validate_filenames.py: Passed (0 errors).uvx ruff check data_structures/binary_tree/merge_two_binary_trees_iterative.py: All checks passed.uvx ruff format --check data_structures/binary_tree/merge_two_binary_trees_iterative.py: 1 file already formatted.python3 -m doctest -v: All 39 doctests passed.pytest --doctest-modules: 3/3 passed.4. Submission Checklist
data_structures/binary_tree/merge_two_binary_trees_iterative.pywith type hints and doctests.merge_two_binary_trees.py.scripts/validate_filenames.pyandruffpass cleanly.work/R23-T029/VARIANT.mdcompares stack depth and runtime with timing table.student/E26B07F0850/R23-T029-upstreamprepared with only code changes.