0% completed
Is linked list necessary for python?
matthew.carnahan1
Jul 6, 2024
If the only advantage to using linked lists for stacks, is it avoids stack overflows, then I don't see why we would use them over a simple list in python. I can't speak for the other programming languages, but it appears to me that the only reason we would have a stack overflow issue in the first set of code, is because we deliberately set a finite size for the stack. If we instead code it up, like it is in the lesson "Operations on Stack", it would allow you to use a simple list, that is dynamically sized, which would in turn avoid the stack overflow problem. A lot simpler code.
Does anyone disagree?
1
0
Comments
Brij Patela year ago
I agree, its the same in Java and JS. If we just don't define a limit for the array when we initialize it don't we just get a stack with dynamic size? I'm not sure what the point of implementing it though a listed list is, in my opinion it just makes it more confusing. ...
Maksim Golubev3 months ago
I'm confused about why the Stack implementation in Python uses a fixed-size list. And why a linked list is used to support dynamic size. This seems unnecessarily complex.
Python's language design already supports dynamic lists, which can be used directly for stack beha...
On this page