Professional Documents
Culture Documents
Lab4 PILA
Lab4 PILA
OBJECT
General object
Specific object
Understand how to perform the ordering step by step, doing the desktop test.
Verify the correct use of the insertion sort algorithm, using an array with data in
disorder.
1. THEORETICAL FRAMEWORK
Introduction to java
Some of its history start in the “early 90s, extending the power of network computing to
the activities of everyday life was a radical vision. In 1991, a small group of Sun engineers
called the "Green Team" believed that the next wave in computing was the union of digital
consumer devices and computers. Led by James Gosling, the team worked around the
clock and created the programming language that would revolutionize our world – Java”.
(Oracle, 2017)
One important part of java is its Java Virtual Machine (JVM) this executes java code, but
is written in platform specific languages such as C/C++/ASM, etc. so JVM is not written
in JAVA and hence cannot be platform independent and Java interpreter is a part of JVM.
(W3schools.in, 2016)
Introduction to eclipse
Eclipse, in the late 1990s, IBM began development of what we now know as Eclipse.
Today we see high adoption rates and evidence of successful application of this
technology across the software industry. The purpose of this article is to review the
inception of Eclipse, to illustrate the role it plays in today's development tools, and to
convey how we see the technology evolving over time. (Cernosek, 2005)
The Eclipse Project was originally created by IBM in November 2001 and supported by
a consortium of software vendors. The Eclipse Foundation was created in January 2004
as an independent not-for-profit corporation to act as the steward of the Eclipse
community. The independent not-for-profit corporation was created to allow a vendor
neutral and open, transparent community to be established around Eclipse. Today, the
Eclipse community consists of individuals and organizations from a cross section of the
software industry. (Cernosek, 2005)
The arrangement for insertion is considers as a simple algorithm, this algorithm has the
characteristic of keeping the regions tidy without ordering of the counterfoil. In every
iteration, the following element without ordering moves up to an appropriate position in
the region where they are tidy. It is much less efficient in big lists, which more algorithms
advanced like quicksort.
- Easy to help
- Efficiently in small sets of information
- Stably (it does not change the relative order of the elements)
In abstract terms, each iteration of an insert order deletes an element from the data entry,
inserting it in the correct position in the already sorted list, until there are no elements in
the entry. The choice of the element to remove from the input is arbitrary.
1. DEVELOPMENT OF AUTO-PRACTICE
STATIC STACK
To create a stack in java we must define the size of the stack, 2 classes will be used,
in the first class called “Method_pila” the different methods that allow the creation of
the stack will be implemented. In the second class called “Main_pila”, will be where
the stack size will be defined, and a menu will be available to perform the different
operations with the stack.
1. Empty. This method allows to give the state of the stack. If the stack is empty,
a Boolean will return true.
This method also allows to solve the problem of underflow, this happens when
you want to eliminate an element from an empty stack.
3. Push. This method, if the stack is not full, allows you to add an element to the
stack.
4. Pop. This method, if the stack is not empty, allows you to remove an element
from the stack.
Part 2: Menu.
In the “main_pila” class, a menu is implemented, which is useful in a dynamic way with
the user to relate the operations that this requires.
The menu will be available until the user enters the number 0.
DYNAMIC STACK
A dynamic stack is one that will not have a defined size. This will be adapted to data
entry and output. They are linear data structures, which store and retrieve their elements
according to a strict order. In a pile the last element to enter or arrive, is the first element
to be attended or leave, hence they are known as LIFO structures.
These stack have the 5 basic operations of the stacks. And additional has an operation
which allows to empty the entire stack.
For the creation of a dynamic stack linked lists are used.
The concept of linked lists, at the moment is not part of the course. That is the reason
why this type of stack will not be implemented in this report.
STACK JAVA LIBRARY
2. Class methods
peek() This method looks at the object at the top of this stack without
removing it from the stack.
push(E item) This method pushes an item onto the top of this stack.
pop() Removes the object at the top of this stack and returns that
object as the value of this function.
To use the Stack class, the first thing to do is import the util.Stack class
Finally the use of methods that can be used according to the needs of the practice. in
this practice the push and pop method has been used.
Finally we can conclude that Stack are structures that allow storing
information, this information is stored in a specific order, the only way to
retrieve the information is in the LIFO mode. That is, the last one to enter
will be the first one to leave.
Stacks like any other information container, can suffer from problems such
as overflow and underflow. For this, the empty and full methods must be
implemented correctly, which will allow solving these problems.
The batteries are used in real life, for when another program is called, the
program that is running does not lose the information. That is to say, they
allow to save the state of the variables at the time the call is made, to
continue occupying them when returning from the subprogram.
5. RECOMMENDATIONS
The teacher should implement the use of the stacks in an easy problem, so that
the student can understand in a better way the use of these.