From b8dfcbaff254a88b9ed37f68a765e457edf8093d Mon Sep 17 00:00:00 2001 From: Rohini Date: Wed, 3 Sep 2025 06:08:09 -0700 Subject: [PATCH 1/9] docs: add template for project proposal (#1) --- courseProjectDocs/project-proposal.md | 34 +++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 courseProjectDocs/project-proposal.md diff --git a/courseProjectDocs/project-proposal.md b/courseProjectDocs/project-proposal.md new file mode 100644 index 000000000000..b9e0847f0dd2 --- /dev/null +++ b/courseProjectDocs/project-proposal.md @@ -0,0 +1,34 @@ +# Project Proposal + + +## Project Overview + +< include overview here > + + +## Key Quality Metrics + + +### Code Structure + +#### Lines of Code + +< include metrics here > + +#### Comment Density + +< include metrics here > + +#### Cyclomatic Complexity + +< include metrics here > + +### Testability + +#### Number of Unit Test Cases + +< include metrics here > + +#### Test Coverage + +< include metrics here > From fc6dd1df35f52fe8a75219c70b95c53348f51834 Mon Sep 17 00:00:00 2001 From: Uzair Mukadam <42241950+uzairmukadam@users.noreply.github.com> Date: Sun, 7 Sep 2025 11:27:51 -0400 Subject: [PATCH 2/9] (docs) add lines of code info to project doc (#2) * script added to calculate LOC and mentioned the count in doc. * LOC script removed --- courseProjectDocs/project-proposal.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/courseProjectDocs/project-proposal.md b/courseProjectDocs/project-proposal.md index b9e0847f0dd2..02912596330e 100644 --- a/courseProjectDocs/project-proposal.md +++ b/courseProjectDocs/project-proposal.md @@ -3,7 +3,7 @@ ## Project Overview -< include overview here > +This repository is a curated collection of algorithmic implementations in Python, designed to serve as a reference, learning resource, and toolkit for developers and students alike. It spans a wide range of domains, including blockchain, ciphers, data compressions, data structures, linear algebra, etc. ## Key Quality Metrics @@ -13,7 +13,20 @@ #### Lines of Code -< include metrics here > +Data Structures Directory: + +1. arrays: 871 +2. binary tree: 4992 +3. disjoint set: 129 +4. hashing: 881 +5. heap: 1310 +6. kd tree: 275 +7. linked list: 2611 +8. queues: 1246 +9. stacks: 1321 +10. suffix tree: 165 +11. trie: 289 +- #### total: 14090 #### Comment Density From b401e1a13e1617523fc639f20414eaefde9fad5f Mon Sep 17 00:00:00 2001 From: Shridhar Vilas Shinde <63049520+shri2606@users.noreply.github.com> Date: Sun, 7 Sep 2025 11:28:51 -0400 Subject: [PATCH 3/9] (feat) added comment density script (#3) Co-authored-by: ss7536 --- courseProjectCode/Metrics/comment_density.py | 109 +++++++++++++++++++ 1 file changed, 109 insertions(+) create mode 100644 courseProjectCode/Metrics/comment_density.py diff --git a/courseProjectCode/Metrics/comment_density.py b/courseProjectCode/Metrics/comment_density.py new file mode 100644 index 000000000000..ca6a0b5a9ac7 --- /dev/null +++ b/courseProjectCode/Metrics/comment_density.py @@ -0,0 +1,109 @@ + + +import os +import sys + +def comment_density(): + + + # Path to data_structures directory + data_structures_path = os.path.join(os.path.dirname(__file__), '..', '..', 'data_structures') + + if not os.path.exists(data_structures_path): + print(f"Error: data_structures directory not found at {data_structures_path}") + return + + total_lines = 0 + comment_lines = 0 + blank_lines = 0 + files_processed = 0 + + + for root, dirs, files in os.walk(data_structures_path): + for file in files: + if file.endswith('.py'): + file_path = os.path.join(root, file) + + try: + with open(file_path, 'r', encoding='utf-8', errors='ignore') as f: + lines = f.readlines() + + file_total = len(lines) + file_comments = 0 + file_blanks = 0 + + in_multiline_comment = False + multiline_delimiter = None + + for line in lines: + stripped_line = line.strip() + original_line = line + + if not stripped_line: + file_blanks += 1 + continue + + # Check single line comments + if stripped_line.startswith('#'): + file_comments += 1 + continue + + # Check multi-line comments + line_is_comment = False + temp_line = original_line + + while True: + if not in_multiline_comment: + # Look for start of multi-line comment + triple_double_pos = temp_line.find('"""') + triple_single_pos = temp_line.find("'''") + + if triple_double_pos != -1 and (triple_single_pos == -1 or triple_double_pos < triple_single_pos): + in_multiline_comment = True + multiline_delimiter = '"""' + line_is_comment = True + temp_line = temp_line[triple_double_pos + 3:] + elif triple_single_pos != -1: + in_multiline_comment = True + multiline_delimiter = "'''" + line_is_comment = True + temp_line = temp_line[triple_single_pos + 3:] + else: + break + else: + + line_is_comment = True + end_pos = temp_line.find(multiline_delimiter) + if end_pos != -1: + in_multiline_comment = False + multiline_delimiter = None + temp_line = temp_line[end_pos + 3:] + else: + break + + if line_is_comment: + file_comments += 1 + + total_lines += file_total + comment_lines += file_comments + blank_lines += file_blanks + files_processed += 1 + + except Exception as e: + continue + + code_lines = total_lines - blank_lines - comment_lines + + # Calculate comment density + non_blank_lines = total_lines - blank_lines + if non_blank_lines > 0: + comment_density = (comment_lines / non_blank_lines) * 100 + else: + comment_density = 0.0 + + print(f"Code lines: {code_lines}") + print(f"Comment lines: {comment_lines}") + print(f"Comment density: {comment_density:.2f}%") + +if __name__ == "__main__": + comment_density() From 082679084ef459667aae553cc9f037a5a922206a Mon Sep 17 00:00:00 2001 From: Rohini Date: Sun, 7 Sep 2025 09:20:31 -0700 Subject: [PATCH 4/9] docs: format and include test metrics (#4) --- courseProjectDocs/project-proposal.md | 52 ++++++++++++++++++--------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/courseProjectDocs/project-proposal.md b/courseProjectDocs/project-proposal.md index 02912596330e..6a47184c2178 100644 --- a/courseProjectDocs/project-proposal.md +++ b/courseProjectDocs/project-proposal.md @@ -3,11 +3,11 @@ ## Project Overview -This repository is a curated collection of algorithmic implementations in Python, designed to serve as a reference, learning resource, and toolkit for developers and students alike. It spans a wide range of domains, including blockchain, ciphers, data compressions, data structures, linear algebra, etc. - +[TheAlgorithms/Python](https://github.com/TheAlgorithms/Python) is an open-source repository for learning, practicing, and understanding algorithms in Python. It offers a curated collection of algorithm implementations that serve as a reference, educational resource, and practical toolkit for both students and developers. It covers a wide range of domains, including blockchain, cryptography, data compression, data structures, linear algebra, and more. ## Key Quality Metrics +For the purpose of this assignment, we will be diving into the **[Data Dtructures](https://github.com/SWEN-777/TheAlgorithms-Python/tree/master/data_structures)** directory to evaluate its key quality metrics. ### Code Structure @@ -15,22 +15,27 @@ This repository is a curated collection of algorithmic implementations in Python Data Structures Directory: -1. arrays: 871 -2. binary tree: 4992 -3. disjoint set: 129 -4. hashing: 881 -5. heap: 1310 -6. kd tree: 275 -7. linked list: 2611 -8. queues: 1246 -9. stacks: 1321 -10. suffix tree: 165 -11. trie: 289 -- #### total: 14090 +| Section | Count | +|---------------|-------| +| Arrays | 871 | +| Binary Tree | 4992 | +| Disjoint Set | 129 | +| Hashing | 881 | +| Heap | 0 | +| KD Tree | 275 | +| Linked List | 2611 | +| Queues | 1246 | +| Stacks | 1321 | +| Suffix Tree | 165 | +| Trie | 289 | +| **Total** | **14090** | #### Comment Density -< include metrics here > +Comment lines: 7160 +Comment density: 50.82% + +> Note: Refer to comment density code [here](https://github.com/SWEN-777/TheAlgorithms-Python/blob/master/courseProjectCode/metrics/comment_density.py) #### Cyclomatic Complexity @@ -40,7 +45,22 @@ Data Structures Directory: #### Number of Unit Test Cases -< include metrics here > +While many examples are provided for the data structure algorithms, the following reflects the number of proper unit tests available in each section: + +| Section | Unit Tests | +|---------------|------------| +| Arrays | 1 | +| Binary Tree | 21 | +| Disjoint Set | 1 | +| Hashing | 2 | +| Heap | 0 | +| KD Tree | 3 | +| Linked List | 13 | +| Queues | 0 | +| Stacks | 1 | +| Suffix Tree | 5 | +| Trie | 2 | +| **Total** | **49** | #### Test Coverage From a36817b8867c248d04df1c611e19bfa23eb27c9f Mon Sep 17 00:00:00 2001 From: Rohini Date: Sun, 7 Sep 2025 10:24:44 -0700 Subject: [PATCH 5/9] (fix) fix broken links and typo (#5) * docs: format and include test metrics * (fix) fix broken links and typo --- courseProjectDocs/project-proposal.md | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/courseProjectDocs/project-proposal.md b/courseProjectDocs/project-proposal.md index 6a47184c2178..46521f681180 100644 --- a/courseProjectDocs/project-proposal.md +++ b/courseProjectDocs/project-proposal.md @@ -7,7 +7,7 @@ ## Key Quality Metrics -For the purpose of this assignment, we will be diving into the **[Data Dtructures](https://github.com/SWEN-777/TheAlgorithms-Python/tree/master/data_structures)** directory to evaluate its key quality metrics. +For the purpose of this assignment, we will be diving into the **[Data Structures](https://github.com/SWEN-777/TheAlgorithms-Python/tree/master/data_structures)** directory to evaluate its key quality metrics. ### Code Structure @@ -35,11 +35,7 @@ Data Structures Directory: Comment lines: 7160 Comment density: 50.82% -> Note: Refer to comment density code [here](https://github.com/SWEN-777/TheAlgorithms-Python/blob/master/courseProjectCode/metrics/comment_density.py) - -#### Cyclomatic Complexity - -< include metrics here > +> Note: Refer to comment density code [here](https://github.com/SWEN-777/TheAlgorithms-Python/blob/master/courseProjectCode/Metrics/comment_density.py) ### Testability @@ -64,4 +60,4 @@ While many examples are provided for the data structure algorithms, the followin #### Test Coverage -< include metrics here > +The repository does not include dedicated test coverage scripts, so an accurate coverage percentage could not be determined. From deff6f3b9599509ec24053605545ec142baf0d16 Mon Sep 17 00:00:00 2001 From: Rohini Date: Sun, 7 Sep 2025 10:30:13 -0700 Subject: [PATCH 6/9] fix: fix typo in project doc (#6) --- courseProjectDocs/project-proposal.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/courseProjectDocs/project-proposal.md b/courseProjectDocs/project-proposal.md index 46521f681180..8dda681328fb 100644 --- a/courseProjectDocs/project-proposal.md +++ b/courseProjectDocs/project-proposal.md @@ -21,7 +21,7 @@ Data Structures Directory: | Binary Tree | 4992 | | Disjoint Set | 129 | | Hashing | 881 | -| Heap | 0 | +| Heap | 1310 | | KD Tree | 275 | | Linked List | 2611 | | Queues | 1246 | @@ -33,6 +33,7 @@ Data Structures Directory: #### Comment Density Comment lines: 7160 + Comment density: 50.82% > Note: Refer to comment density code [here](https://github.com/SWEN-777/TheAlgorithms-Python/blob/master/courseProjectCode/Metrics/comment_density.py) From b3ea1e2534fe06eb7a9262aa9034bc96ffa2a7f5 Mon Sep 17 00:00:00 2001 From: Uzair Mukadam <42241950+uzairmukadam@users.noreply.github.com> Date: Sun, 14 Sep 2025 11:33:26 -0400 Subject: [PATCH 7/9] Test requirements * Requirements and Test Oracles document added * Requirements document updated --- courseProjectDocs/requirements-and-oracles.md | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 courseProjectDocs/requirements-and-oracles.md diff --git a/courseProjectDocs/requirements-and-oracles.md b/courseProjectDocs/requirements-and-oracles.md new file mode 100644 index 000000000000..52c9be1ff4ce --- /dev/null +++ b/courseProjectDocs/requirements-and-oracles.md @@ -0,0 +1,22 @@ +# Requirements and Test Oracles + +## Functional Requirements + +The described data structures should be able to: +1. **Traversal:** Enable traversal methods (e.g., in-order, pre-order, post-order for trees; forward/backward for linked lists). +2. **Sorting:** Provide built-in or integrable sorting mechanisms where applicable. + + +## Non-Functional Requirements + +The data structure should ensure: +1. **Testability:** Design should allow easy integration with unit testing frameworks. + + +## Test Oracles + +| Requirement ID | Requirement Description | Test Oracle (Expected Behavior) | +|----------------|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------| +| FR-1 | Enable traversal methods (e.g., in-order, pre-order, post-order for trees; forward/backward for linked lists) | Traversal methods should return elements in the correct sequence based on the traversal type. | +| FR-2 | Provide built-in or integrable sorting mechanisms where applicable | Sorting operations should generate a correctly ordered sequence of elements. | +| NFR-1 | Design should allow easy integration with unit testing frameworks | All public methods should be testable via standard unit testing frameworks. | \ No newline at end of file From 16709f69c39697d76c3090f1880979b64d666538 Mon Sep 17 00:00:00 2001 From: Rohini Date: Sun, 14 Sep 2025 08:44:08 -0700 Subject: [PATCH 8/9] docs: add reqs and test oracles --- courseProjectDocs/requirements-and-oracles.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/courseProjectDocs/requirements-and-oracles.md b/courseProjectDocs/requirements-and-oracles.md index 52c9be1ff4ce..802af6760f42 100644 --- a/courseProjectDocs/requirements-and-oracles.md +++ b/courseProjectDocs/requirements-and-oracles.md @@ -5,12 +5,16 @@ The described data structures should be able to: 1. **Traversal:** Enable traversal methods (e.g., in-order, pre-order, post-order for trees; forward/backward for linked lists). 2. **Sorting:** Provide built-in or integrable sorting mechanisms where applicable. +3. **Search & Access:** Support efficient search and retrieval of elements. +4. **Error Handling:** Gracefully handle invalid operations (e.g., removing from an empty queue). ## Non-Functional Requirements The data structure should ensure: 1. **Testability:** Design should allow easy integration with unit testing frameworks. +2. **Performance / Efficiency:** Operations should be optimized for time and space complexity (e.g., O(1) for stack push/pop). +3. **Scalability:** Data structures should handle large datasets without significant performance degradation. ## Test Oracles @@ -19,4 +23,8 @@ The data structure should ensure: |----------------|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------| | FR-1 | Enable traversal methods (e.g., in-order, pre-order, post-order for trees; forward/backward for linked lists) | Traversal methods should return elements in the correct sequence based on the traversal type. | | FR-2 | Provide built-in or integrable sorting mechanisms where applicable | Sorting operations should generate a correctly ordered sequence of elements. | -| NFR-1 | Design should allow easy integration with unit testing frameworks | All public methods should be testable via standard unit testing frameworks. | \ No newline at end of file +| FR-3 | Support efficient search and retrieval of elements | For a known dataset, search operations should return the correct element or index in expected time (e.g., O(log n)). | +| FR-4 | Gracefully handle invalid operations (e.g., removing from an empty queue) | Invalid operations should raise appropriate exceptions or return error codes without crashing. +| NFR-1 | Design should allow easy integration with unit testing frameworks | All public methods should be testable via standard unit testing frameworks. | +| NFR-2 | Data structures should handle large datasets without significant performance degradation | Usage with large datasets should show stable performance metrics and no memory overflows or timeouts. | +| NFR-3 | Operations should be optimized for time and space complexity (e.g., O(1) for stack push/pop) | Operations should meet the expected time/space complexity bounds under typical scenarios. | \ No newline at end of file From a9ef40d6708a37f84fc723d76ded580463389c89 Mon Sep 17 00:00:00 2001 From: ss7536 Date: Sun, 14 Sep 2025 17:22:44 -0400 Subject: [PATCH 9/9] requirements & test oracle --- courseProjectDocs/requirements-and-oracles.md | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/courseProjectDocs/requirements-and-oracles.md b/courseProjectDocs/requirements-and-oracles.md index 802af6760f42..f0dd39215b59 100644 --- a/courseProjectDocs/requirements-and-oracles.md +++ b/courseProjectDocs/requirements-and-oracles.md @@ -3,28 +3,36 @@ ## Functional Requirements The described data structures should be able to: + 1. **Traversal:** Enable traversal methods (e.g., in-order, pre-order, post-order for trees; forward/backward for linked lists). 2. **Sorting:** Provide built-in or integrable sorting mechanisms where applicable. 3. **Search & Access:** Support efficient search and retrieval of elements. 4. **Error Handling:** Gracefully handle invalid operations (e.g., removing from an empty queue). - +5. **Insertion & Deletion:** Allow insertion and deletion operations at appropriate positions. +6. **Integration with Algorithms:** Data structures shall support direct usage with sorting, searching, or graph algorithms. ## Non-Functional Requirements The data structure should ensure: + 1. **Testability:** Design should allow easy integration with unit testing frameworks. 2. **Performance / Efficiency:** Operations should be optimized for time and space complexity (e.g., O(1) for stack push/pop). 3. **Scalability:** Data structures should handle large datasets without significant performance degradation. - +4. **Reliability:** Functions should consistently return correct results under normal usage. +5. **Maintainability:** Code should be modular, well-documented, and easy to update or extend. ## Test Oracles -| Requirement ID | Requirement Description | Test Oracle (Expected Behavior) | -|----------------|------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------| -| FR-1 | Enable traversal methods (e.g., in-order, pre-order, post-order for trees; forward/backward for linked lists) | Traversal methods should return elements in the correct sequence based on the traversal type. | -| FR-2 | Provide built-in or integrable sorting mechanisms where applicable | Sorting operations should generate a correctly ordered sequence of elements. | -| FR-3 | Support efficient search and retrieval of elements | For a known dataset, search operations should return the correct element or index in expected time (e.g., O(log n)). | -| FR-4 | Gracefully handle invalid operations (e.g., removing from an empty queue) | Invalid operations should raise appropriate exceptions or return error codes without crashing. -| NFR-1 | Design should allow easy integration with unit testing frameworks | All public methods should be testable via standard unit testing frameworks. | -| NFR-2 | Data structures should handle large datasets without significant performance degradation | Usage with large datasets should show stable performance metrics and no memory overflows or timeouts. | -| NFR-3 | Operations should be optimized for time and space complexity (e.g., O(1) for stack push/pop) | Operations should meet the expected time/space complexity bounds under typical scenarios. | \ No newline at end of file +| Requirement ID | Requirement Description | Test Oracle (Expected Behavior) | +| -------------- | ------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------- | +| FR-1 | Enable traversal methods (e.g., in-order, pre-order, post-order for trees; forward/backward for linked lists) | Traversal methods should return elements in the correct sequence based on the traversal type. | +| FR-2 | Provide built-in or integrable sorting mechanisms where applicable | Sorting operations should generate a correctly ordered sequence of elements. | +| FR-3 | Support efficient search and retrieval of elements | For a known dataset, search operations should return the correct element or index in expected time (e.g., O(log n)). | +| FR-4 | Gracefully handle invalid operations (e.g., removing from an empty queue) | Invalid operations should raise appropriate exceptions or return error codes without crashing. | +| FR-5 | Allow insertion and deletion operations at appropriate positions | After insertion or deletion, the data structure should reflect the updated state accurately. | +| FR-6 | Data structures shall support direct usage with sorting, searching, or graph algorithms | The data structure should be able to produce correct results when used with algorithms like sorting, searching, etc. | +| NFR-1 | Design should allow easy integration with unit testing frameworks | All public methods should be testable via standard unit testing frameworks. | +| NFR-2 | Data structures should handle large datasets without significant performance degradation | Usage with large datasets should show stable performance metrics and no memory overflows or timeouts. | +| NFR-3 | Operations should be optimized for time and space complexity (e.g., O(1) for stack push/pop) | Operations should meet the expected time/space complexity bounds under typical scenarios. | +| NFR-4 | Functions should consistently return correct results under normal usage | Repeated calls with valid inputs should yield consistent and correct outputs. | +| NFR-5 | Code should be modular, well-documented, and easy to update or extend | Code analysis and reviews should confirm modularity, ease to update, and presence of meaningful documentation. |