data structure
-
Heya, Just a quick question. I am writing a stack application in which there is one requirement that data structure must make use of a block of memory allocated when the stack is constructed. Now which data stucture is most appropriate for this. Is it sensible to use linked list or not. ta James
-
Heya, Just a quick question. I am writing a stack application in which there is one requirement that data structure must make use of a block of memory allocated when the stack is constructed. Now which data stucture is most appropriate for this. Is it sensible to use linked list or not. ta James
I think you should put on your flame-retardant suit.
-
Heya, Just a quick question. I am writing a stack application in which there is one requirement that data structure must make use of a block of memory allocated when the stack is constructed. Now which data stucture is most appropriate for this. Is it sensible to use linked list or not. ta James
A Linked list, by its very nature, is dynamic; you can't use a stack for it. Unless I'm making a huge mistake (and I've made plenty in the past ;)), you are going to be stuck with arrays*. * You _could_ also use fixed-size stacks and queues and dequeues, but they're just sexed up arrays. :-D
Cheers, Vikram.
"If a trend is truly global, then that trend ought to be visible across ANY subset of that data" - fat_boy
-
Heya, Just a quick question. I am writing a stack application in which there is one requirement that data structure must make use of a block of memory allocated when the stack is constructed. Now which data stucture is most appropriate for this. Is it sensible to use linked list or not. ta James
Out! Out! Out! Out damned spot! You have soiled our lounge enough! For this kind of dirty talk you post in the forums! Hence the massive CLICK HERE! tagged with a pretty and upright exclamation point so that you may look at it and eject and stutter your verbal wonder and awe that such technology exists as may transfer you to another page where you could post your response with little fear that black hooded executioners such as many developers you will find crawling through this swamp known as the lounge that happens to be the incorrect location to post programming questions because it is where we lounge[^] and not discuss direct programming questions because those questions are to be posted in the proper location the access of which begins with the blue hyperlink that legibly reads click here.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook "There is no wealth like knowledge, no poverty like ignorance." Ali ibn Abi Talib "Animadvertistine, ubicumque stes, fumum recta in faciem ferri?"
modified on Friday, December 14, 2007 1:11:59 AM
-
A Linked list, by its very nature, is dynamic; you can't use a stack for it. Unless I'm making a huge mistake (and I've made plenty in the past ;)), you are going to be stuck with arrays*. * You _could_ also use fixed-size stacks and queues and dequeues, but they're just sexed up arrays. :-D
Cheers, Vikram.
"If a trend is truly global, then that trend ought to be visible across ANY subset of that data" - fat_boy
Going by Wikipedia, you can use a linked list as the basis of a stack. http://en.wikipedia.org/wiki/Stack_%28data_structure%29#Implementation[^]
-
A Linked list, by its very nature, is dynamic; you can't use a stack for it. Unless I'm making a huge mistake (and I've made plenty in the past ;)), you are going to be stuck with arrays*. * You _could_ also use fixed-size stacks and queues and dequeues, but they're just sexed up arrays. :-D
Cheers, Vikram.
"If a trend is truly global, then that trend ought to be visible across ANY subset of that data" - fat_boy
Vikram A Punathambekar wrote:
A Linked list, by its very nature, is dynamic; you can't use a stack for it.
A linked list by it's very nature is in fact a stack without push and pop functions.
xacc.ide
IronScheme a R5RS-compliant Scheme on the DLR
The rule of three: "The first time you notice something that might repeat, don't generalize it. The second time the situation occurs, develop in a similar fashion -- possibly even copy/paste -- but don't generalize yet. On the third time, look to generalize the approach." -
Heya, Just a quick question. I am writing a stack application in which there is one requirement that data structure must make use of a block of memory allocated when the stack is constructed. Now which data stucture is most appropriate for this. Is it sensible to use linked list or not. ta James
james_dixon_2008 wrote:
Just a quick question. I am writing a stack application in which there is one requirement that data structure must make use of a block of memory allocated when the stack is constructed. Now which data stucture is most appropriate for this. Is it sensible to use linked list or not.
Your best bet would be to ask this over at the Mathematics and Algorithms[^] forum. (if it were me, I'd just allocate an array and keep an index to the top of the stack. since you're dealing with a fixed size predetermined from the start, that's how I'd do it.)