0622-1114405001-楊能安 - #1320
Open
hosiyaluna wants to merge 4 commits into
Open
0622-1114405001-楊能安#1320hosiyaluna wants to merge 4 commits into
hosiyaluna wants to merge 4 commits into
Conversation
- Task 1: Small array with target found (middle position) - Task 2: Large array with target found (performance comparison) - Task 3: Edge case - target not found Total 12 test cases covering: - Basic correctness (linear vs binary) - Performance comparison (O(n) vs O(log n)) - Edge cases (not found, boundary conditions)
- Implemented linear_search: O(n) time complexity - Implemented binary_search: O(log n) time complexity - Added SearchResult dataclass for structured output - Added format_output helper for display - All 12 tests passing Performance metrics: - Binary search ~7x faster on 10,000 elements - Correct handling of edge cases (not found, boundaries)
- 開工前必答 5 個問題詳細說明 - 12 個 test case 的設計流程 - 重點設計決策(為什麼分 3 個 Task) - AI 協作原則和自我檢查清單
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.
This pull request implements and documents a comprehensive solution for comparing binary search and linear search, including code, test cases, and detailed documentation. The main focus is on correctness, performance measurement, and thorough edge case handling. The most important changes are summarized below:
Implementation of Search Algorithms:
Added
linear_searchandbinary_searchfunctions insearch.py, both returning a unifiedSearchResultdataclass that tracks whether the target was found, its index, and the number of comparisons performed.Added a
format_outputfunction to standardize result output for both search algorithms.Testing and Validation:
test_search.pywith 12 pytest-based unit tests, covering small and large arrays, performance comparisons, and a variety of edge cases (target at start/end, single-element arrays, target not present, etc.), ensuring both correctness and performance differences between the algorithms.Documentation and Design Rationale:
Added
TASK_SUMMARY.mddocumenting the three main testing tasks, test results, file structure, and next steps for PR submission.Added
AI_LOG.mddetailing design decisions, function signatures, exception handling, edge cases, TDD process, and acceptance criteria for the solution.These changes together provide a robust, well-tested, and well-documented solution for comparing binary search and linear search, following best practices in software engineering.