Advanced Python Recursion Assignment
Advanced Python Recursion Assignment
Minor syntax errors can prevent test scripts from executing correctly, resulting in failed tests, which negatively impacts grading since functionality is a core criterion. Carefully resolving syntax issues ensures accurate evaluation of the solution logic and meets the requirement of correct execution stipulated in the assignment .
Including functions with 'pass' statements indicates that the student acknowledges the required functions but didn't implement them. This approach might be used to maintain structural completeness and avoid undefined function errors during testing. It also signals transparency about the uncompleted sections to the graders .
Analyzing time complexity is crucial because it ensures the function 'compute_power' runs efficiently, especially for large inputs. The complexity can be reduced below O(m) by utilizing an approach such as exponentiation by squaring. This method reduces the number of multiplications by computing n^m recursively as (n^(m/2) * n^(m/2)) if m is even, or n*(n^(m-1)/2 * n^(m-1)/2) if m is odd, thereby achieving a logarithmic time complexity of O(log m).
The 'generate sequence' function handles odd and even numbers by applying different transformations. If the number is even, it becomes half its value (n = n/2). If the number is odd, it undergoes the transformation n = 3*n + 1 . The sequence converges to 1 due to the properties of the algorithm, known as the Collatz Conjecture, which posits that this recursive transformation always reaches 1 irrespective of the starting integer .
Avoiding predefined power operators forces students to engage with the underlying mathematics of exponentiation, such as applying recursion or loops manually to devise an efficient algorithm. This exclusion promotes deeper understanding and skills in algorithm design and complexity management, which are critical in computer science education .
The submission requires a single Python file named assignment3.py, beginning with comments for author and student number . Additionally, if the time complexity is discussed, a separate PDF named Question2Complexity.pdf must be submitted. Both files must be uploaded individually to Blackboard without being zipped . Following these conventions ensures the test scripts function correctly and the assignment is graded accurately .
Helper functions starting with an underscore are allowed in the assignment to aid the primary functions without cluttering their logic. This allows for modular and readable code . There is no explicit limit on the number of these functions, as long as total line count stays under 500 and the functions support rather than overlap with the main task .
In Assignment 3, code quality is assessed based on readability, modularity, and proper in-code documentation in addition to functional correctness . This evaluation is integral as it encourages best coding practices, ensuring solutions are understandable and maintainable, which is essential for collaborative and long-term software development .
A complete submission for Assignment 3 must include a Python file named assignment3.py containing solutions to all questions, with unsolved functions using 'pass' . If the complexity of 'compute_power' is addressed, it requires a separate PDF file named Question2Complexity.pdf explaining why the implementation has a time complexity lower than O(m).
The plagiarism policy for Assignment 3 strictly prohibits copying from other students or the internet, as well as sharing one's code with others. Any detected plagiarism will initiate a fraud process in accordance with exam regulations, potentially leading to academic penalties . This policy underscores the importance of individual effort and originality in programming assignments .