data structures - Java and Different Types of Stacks -


Currently only the stack I know is anything about vector, I usually use it instead of the array But I think other types of stacks and they all correspond to different jobs.

I am currently working, for this project, I need to put objects inside a stack in a certain position, not always in front of the stack and I have the impression that vector this job Can not be the best class for.

Can anyone give me a brief description of the other types of stacks available to me with Java language and their advantages and disadvantages? These names are homogeneous? As if they use only in Java language or do they use computer science as general terms?

Thank you

You mention that you have things in your 'pile' Are putting in the middle. ' Then I would recommend using the LinkedList

If you already got the condition that you need to enter a new element, then it's time to insert it < Code> O (1) . For vector it is o (n) because you need to copy the backing array.

Linkedist also supports operation like stack, such as

for the data structure to see what all this offers.

To answer your last question. In the computer science, linkedlist is a very common data structure, it is also commonly used to implement the stack because the push and pop operation continuous time, O (1) .


Comments

Popular posts from this blog

windows - Heroku throws SQLITE3 Read only exception -

lex - Building a lexical Analyzer in Java -

python - rename keys in a dictionary -