It's UWAweek 47

help3001

This forum is provided to promote discussion amongst students enrolled in CITS3001 Advanced Algorithms.

Please consider offering answers and suggestions to help other students! And if you fix a problem by following a suggestion here, it would be great if other interested students could see a short "Great, fixed it!"  followup message.

How do I ask a good question?
Displaying the 2 articles in this topic
Showing 2 of 202 articles.
Currently 18 other people reading this forum.


 UWA week 35 (2nd semester, week 6) ↓
SVG not supported

Login to reply

👍?
helpful
6:30pm Sat 31st Aug, Mahit G.

I used recursion to solve this problem in my first try, it solved all the test-cases except the last one giving a max recursive depth error, I then used stack and iterative method and seemed to have passed all the cases, after a bit of research(chatgpt) told me that recursion in python has a limit which when using stack it is not there. I just wanted to confirm if this is true or if the problem could have been done through recursion. If it is true, is the iterative implementation generally better everytime?


 UWA week 36 (2nd semester, mid-semester break) ↓
SVG not supported

Login to reply

👍?
helpful
12:08pm Mon 2nd Sep, Andrew G.

"Mahit Gupta" <23*9*2*5@s*u*e*t*u*a*e*u*a*> wrote:
> I used recursion to solve this problem in my first try, it solved all the test-cases except the last one giving a max recursive depth error, I then used stack and iterative method and seemed to have passed all the cases, after a bit of research(chatgpt) told me that recursion in python has a limit which when using stack it is not there. I just wanted to confirm if this is true or if the problem could have been done through recursion. If it is true, is the iterative implementation generally better everytime?
Yes, Python has a recursion depth limit that defaults to 1000 in the most common implementation (CPython). This can be adjusted programmatically, but in Python I would generally prefer to just use an iterative implementation. There is no mathematical difference, after all, since recursion is just using the call stack as its stack data structure.

The University of Western Australia

Computer Science and Software Engineering

CRICOS Code: 00126G
Written by [email protected]
Powered by history
Feedback always welcome - it makes our software better!
Last modified  8:08AM Aug 25 2024
Privacy policy