Question

In: Computer Science

Discuss the stack data structure. What is it? How can it be used? What support exists...

Discuss the stack data structure. What is it? How can it be used? What support exists for stacks in the Java Class Library Collections Framework? Do you think this support is easy to understand and use? Why or why not? Discuss the pros and cons of creating your own stack classes vs. using those provided by the Java Class Library Collections Framework. Make sure you take into consideration the ability to handle any kind of objects (generics).

Solutions

Expert Solution

ANSWER;

stack data structure is a linear data structure which follows a particular order in the operations which are performed. there are two types of order which stack data structure follow which are

LIFO (Last in first out )

FIFO (First in Last out )

so in stack data structure, there are basically four types of operations which are as follows:

Push: add an item in stack
Pop: remove an item in stack
Top: Returns the top element of the stack.
isEmpty : returned true if the stack is empty, else false
In Java, dynamically allocated data structures which are ArrayList, LinkedList, Vector, Stack, HashSet, HashMap, Hashtable are supported in Collection Framework, which mandates the common behaviors of all the classes.

There are some pros and some cons of creating your own stack classes which suppose that you are working on an application and there are some classes which you are being used so you made custom classes and these classes can be used without any new code. But the classes which are already there are more optimized and these classes are also error proof and it can be used in any situation.


Related Solutions

In assignment 1 you had used the data structure called Stack to evaluate arithmetic expressions by...
In assignment 1 you had used the data structure called Stack to evaluate arithmetic expressions by first converting the given infixed expressions to postfixed expressions, and then evaluated the post fixed expression. Repeat the exercise for this assignment (assignment 2) by using the data structure called Binary Trees. Your output must display the original expression, the postfixed expression representing the Binary tree, and the evaluated result. Please bear in mind that a given expression could result in one of the...
Assignment #2 (JAVA) In assignment 1 you had used the data structure called Stack to evaluate...
Assignment #2 (JAVA) In assignment 1 you had used the data structure called Stack to evaluate arithmetic expressions by first converting the given infixed expressions to postfixed expressions, and then evaluated the post fixed expression. Repeat the exercise for this assignment (assignment 2) by using the data structure called Binary Trees. Your output must display the original expression, the postfixed expression representing the Binary tree, and the evaluated result. Please bear in mind that a given expression could result in...
For the following Questions : Describe the operation of a stack mechanism used to support subroutines...
For the following Questions : Describe the operation of a stack mechanism used to support subroutines in a microprocessor. Describe the operation of the Register Windows mechanism used to support subroutines in a microprocessor. Describe the operation of the coloring mechanism used to support subroutines in a microprocessor. Which of the three mechanisms is the least efficient in terms of performance (CPI) and why. Which of the three mechanisms is the most efficient in terms of performance (CPI) and why.
What are EAI, EII, and ETL and how are each used to support data integration applications?...
What are EAI, EII, and ETL and how are each used to support data integration applications? Your answer should include a specific example of an application for each (not a tool/software example, but an example of how they are used). ***Limit your post to 300 words or less
Discuss how the HL7 reference information model (RIM) can be used for developing clinical decision support...
Discuss how the HL7 reference information model (RIM) can be used for developing clinical decision support systems (CDSS).
Thought on working with Data. What can we used data. How can we work with it....
Thought on working with Data. What can we used data. How can we work with it. I need a paragraph
Compare a data warehouse used for decision support to an operational database. How do the data...
Compare a data warehouse used for decision support to an operational database. How do the data warehouse and the operational database differ in their purpose, their structure, the technology they use, and the way they are managed? Why would a company need both?
Discuss the trade-off theory of capital structure. What empirical support is there for the theory? (maximum...
Discuss the trade-off theory of capital structure. What empirical support is there for the theory? (maximum length guide: about 150 words)
Introduced to data structure using java 2)One of the applications of stack is to convert infix...
Introduced to data structure using java 2)One of the applications of stack is to convert infix expressions to postfix. Given the following infix expression, use the stack method to convert it to postfix. Show your work. x - y / (a + b) + z 3)write a generic method to find the maximum of three variables of generic type (i.e. type T). Note that you must use the compareTo method to compare the values. Also, the code must return one...
Discuss what fiscal policy is and how it can be used to close a recessionary gap...
Discuss what fiscal policy is and how it can be used to close a recessionary gap or an inflationary gap.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT