You are on page 1of 17

FORMATO DE GUÍA DE PRÁCTICA DE LABORATORIO / TALLERES / CENTROS DE

SIMULACIÓN – PARA DOCENTES

CARRERA: CIENCIAS DE LA COMPUTACIÓN ASIGNATURA: ESTRUCTURA DE DATOS


NRO. PRÁCTICA: 4 TÍTULO PRÁCTICA: PILAS
INTEGRANTE(S): SANTIAGO VIZCAINO, ANDRES GUEVARA

OBJECT

General object

 To learn the use, implementation and development of stackable data structures


known as stack, with the help of the java programming language.

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.

 Determine the effectiveness of the algorithm, observing the time in which it


performs the ordering.

1. THEORETICAL FRAMEWORK

Introduction to java

Java is an object-oriented programing language, is independent which means it can be run


on any operating system with any type of processor as long as the java interpreter is
available on the system. (W3schools.in, 2016)

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)

Eclipse is a community for individuals and organizations who wish to collaborate on


commercially-friendly open source software. Its projects are focused on building an open
development platform comprised of extensible frameworks, tools and runtimes for
building, deploying and managing software across the lifecycle. The Eclipse Foundation
helps cultivate both an open source community and an ecosystem of complementary
products and services. (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)

Summery method of insertion

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

- Efficiently in sets of information that already are arranged substantially

- 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.

Part 1: Determine the size of the stack

In this part, we must enter the

Illustration 1: size of the stack


Part 2: Stack operations

This part will be divided into 5 fundamental stack operations.

Illustration 2: Metodos_pila class.

 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.

Illustration 3: empty method algorithm.


 2. Full. This method allows to give the state of the stack. If the stack is full, a
Boolean value will return true.
This method also allows you to solve the overflow problem, this happens when
you want to add an element to a full stack.

Illustration 4: full method algorithm.

 3. Push. This method, if the stack is not full, allows you to add an element to the
stack.

Illustration 5: push method algorithm.

 4. Pop. This method, if the stack is not empty, allows you to remove an element
from the stack.

Illustration 6: pop method algorithm.


 5. Show Stack. This method, if the stack is not empty, allows to show all the
elements of the stack.

Illustration 7: show stack method algorithm.

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.

Illustration 8: menú algorithm.


Part 3: desktop test

In this part, we can determinate the size of stack.

Illustration 9: size of stack

In this part, we can see the menu.

Illustration 10: menu.


In this part, we can see the method push working. And overflow problem solved.

Illustration 11: add element to Stack.

Illustration 12 overflow problem solved.


In this part, we can see the method pop working. And underflow problem solved.

Illustration 13: underflow problem solved.

Illustration 14: delete element to Stack.


In this part, the stack is showing.

Illustration 15: show stack.

 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

The java.util.Stack library represents a last-in-first-out (LIFO) stack of objects. It extends


class Vector with five operations that allow a vector to be treated as a stack. The usual
push and pop operations are provided, as well as a method to peek at the top item on the
stack, a method to test for whether the stack is empty, and a method to search the stack
for an item and discover how far it is from the top.
When a stack is first created, it contains no items.
With this way of creating Stack we can use not only the element that is on the top of the
stack, but you can also get any value that is in the stack with the help of their methods.

This package contains the 2 classes:


1. Class constructors.

 Stack()  This constructor creates an empty stack.

2. Class methods

 empty()  This method tests if this stack is empty.

 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.

 search(Object o)  This method returns the 1-based position where an


object is on this stack.

 pop()  Removes the object at the top of this stack and returns that
object as the value of this function.

Part 1: Stack algorithm.

To use the Stack class, the first thing to do is import the util.Stack class

Illustration 16: import class.


The second action to use the Stack class is to instantiate an object to the class

Illustration 17: instantiate an object.

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.

Illustration 18: used methods.


2. RESOURCES USED
 java
 computer
 Internet
3. RESULTS
- STATIC STACK

With this program we got a way to make a Static Stack.

The result of the algorithm is the creation of a Static Stack.


- STACK LYBRARY

With this library we got a way to make a Stack.

The result of this implementation is the creation of a Stack.


4. CONCLUSIONS

 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.

You might also like