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

CS 400 Assignment 4 Stack application: postfix expression evaluation. Description: - The stack data structure can...
CS 400 Assignment 4 Stack application: postfix expression evaluation. Description: - The stack data structure can be used to evaluate postfix expressions. Please refer to the first 14 pages of this tutorial for postfix expression evaluation: http://www.cs.nthu.edu.tw/~wkhon/ds/ds10/tutorial/tutorial2.pdf Requirement: - deal with single digit positive integers only. Operands and operators are fully separated by space. - learn and use STL stack: http://www.cplusplus.com/reference/stack/stack/ - learn and use isdigit(): http://www.cplusplus.com/reference/cctype/isdigit/ - take in a postfix arithmetic expression from cin, and evaluate its value....
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...
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.
Be able to explain how s Stack can be used to determine the validity of parentheses...
Be able to explain how s Stack can be used to determine the validity of parentheses in an arithmetic expression such as: *  ( 2 + 4 ) * ( 8 – 5 ) or a program code such as the following: class ABC {     ABC( int x)      {      } } Be able to determine the runtime complexity of: A Java assignment statement A single loop Nested loop Given that for any polynomial of degree n, p(x) = anxn + an-1...
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?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT