You are on page 1of 16

FORMATO DE GUA DE PRCTICA DE LABORATORIO / TALLERES / CENTROS DE

SIMULACIN PARA DOCENTES

CARRERA: CIENCIAS DE LA COMPUTACIN ASIGNATURA: ESTRUCTURA DE DATOS


NRO. PRCTICA: 3 TTULO PRCTICA: MTODOS DE ORDENACIN SELECCION
INTEGRANTE(S): SANTIAGO VIZCAINO, ANDRES GUEVARA

OBJECT

General object

Learn the correct use of the insertion sort algorithm, with the creation of an array
with data in disorder, to verify how the ordering process is performed, and
determine the effectiveness of the algorithm.

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 PRACTICE

Part 1: creating and filling the array

In this part, we must enter the long of the bi-dimensional array. After that, depending on
the size of the array, you enter the values that correspond to each element.
Part 2: data validation

Using a Boolean variable, a "do While" loop, and try and catch methods. We make sure
that the values entered by the user are just numbers. placing in the try method, reading
through the class buffer reader, we can handle the exception in the catch, and prevent
some failure in data entry bug the program, and using the if loop, we force the entered
data to be only numbers. Is the same with the values that will be entered in the matrix

Ilustracin 1 validacin del tamao del array

Ilustracin 2 validacin de los nmeros ingresados por teclado


Part 2: insertion sort algorithm.

Array is imaginary divided into two parts, sorted one and unsorted one. At the beginning,
sorted part contains first element of the array and unsorted one contains the rest. At every
step, algorithm takes first element in the unsorted part and inserts it to the right place of
the sorted one. When unsorted part becomes empty, algorithm stops.

The main operation of the algorithm is insertion. The task is to insert a value into the
sorted part of the array.

The simplest way to insert next element into the sorted part is to sift it down, until it
occupies correct position. Initially the element stays right after the sorted part. At each
step algorithm compares the element with one before it and, if they stay in reversed order,
swap them.

Loop over positions in the array, starting with index 1. Each new position is like the new
card handed to you by the dealer, and you need to insert it into the correct place in the
sorted subarray to the left of that position.
In essence, the sort selection is this part.

Note: all "System.out.print" statements are used to print the motions that make this
algorithm into a table.

Part 4: printing

We use for loops to print the array.


Part 5: desktop test

In this part, we can see the validation is working.

In this part we ask for the values to make the array. Check that the data is written without
order.
First cycle: for loop.

Variable i It takes the start value that is 0.

Variable pos It take the value of i

Vector[pos] In this case, the value on position (0), is 9

The algorithm have this statement.

Then, as the statement forces it to start when the position is greater than 0, in this first
step it will not enter the while loop.
So the values dont change.
We do this because in this algorithm, the first position is sorted.

Variable lista Shows how the vector remains after the first cycle.
Second cycle: for loop.

Variable i It takes the next value that is 1.

Variable pos It take the value of i, so now is -1-

Vector[pos] In this case, the value on position (1), is -1-

Vector[pos-1] The position is (0) so the value is -9-

Variable aux It take of value of Vector[pos]-1-

Like values -9- is greater than values -1-. And the position is bigger than (0). The while
loop is running.

Vector[pos] Took the value of Vector[pos-1], in this case, now its value is -1-

Variable pos This variable is less 1. Now its values is -0-.

Then, as the statement forces it to start when the position is greater than 0. The boucle
while end.

Vector[pos] Now the position is (0) take the value of aux, -1-

Variable lista Shows how the vector remains after the second cycle.
Third cycle: for loop.

Variable i It takes the next value that is 2.

Variable pos It take the value of i, so now is -2-

Vector[pos] In this case, the value on position (2), is -6-

Vector[pos-1] The position is (1) so the value is -9-

Variable aux It take of value of Vector[pos], -6-

Like values -9- is greater than values -6-. And the position is bigger than (0). The while
loop starts.

Vector[pos] Took the value of Vector[pos-1], in this case, now its value is -9-

Variable pos This variable is less 1. Now its values is -1-.

While loop makes the comparison Vector [pos-1], the position is (0), and the values is
-1-, is greater than aux, -6-? It is not so the boucle while end.

Vector[pos] Now the position is (1) take the value of aux, -6-

Variable lista Shows how the vector remains after the third cycle.
Fourth cycle: for loop.

Variable i It takes the next value that is 3.

Variable pos It take the value of i, so now is -3-

Vector[pos] In this case, the value on position (3), is -3-

Vector[pos-1] The position is (2) so the value is -9-

Variable aux It take of value of Vector[pos], -3-

Like values -9- is greater than values -3-. And the position is bigger than (0). The while
loop starts.

Vector[pos] Took the value of Vector[pos-1], in this case, now its value is -9-

Variable pos This variable is less 1. Now its values is -2-.

While loop makes the comparison Vector [pos-1], the position is (1), and the values is
-6-, is greater than aux, -3-? Yes it is, so while loop starts again.

Vector[pos] Took the value of Vector[pos-1], in this case, now its value is -6-

Variable pos This variable is less 1. Now its values is -1-.

While loop makes the comparison Vector [pos-1], the position is (0), and the values is
-1-, is greater than aux, -3-? It is not, so the boucle while end.

Vector[pos] Now the position is (1) take the value of aux, -3-

Variable lista Shows how the vector remains after the third cycle.
Fifth cycle: for loop.

Variable i It takes the next value that is 4.

Variable pos It take the value of i, so now is -4-

Vector[pos] In this case, the value on position (4), is -4-

Vector[pos-1] The position is (3) so the value is -9-

Variable aux It take of value of Vector[pos], -4-

Like values -9- is greater than values -4-. And the position is bigger than (0). The while
loop starts.

Vector[pos] Took the value of Vector[pos-1], in this case, now its value is -9-

Variable pos This variable is less 1. Now its values is -3-.

While loop makes the comparison Vector [pos-1], the position is (2), and the values is
-6-, is greater than aux, -4-? Yes it is, so while loop starts again.

Vector[pos] Took the value of Vector[pos-1], in this case, now its value is -6-

Variable pos This variable is less 1. Now its values is -1-.

While loop makes the comparison Vector [pos-1], the position is (1), and the values is
-3-, is greater than aux, -4-? It is not, so the boucle while end.

Vector[pos] Now the position is (2) take the value of aux, -4-
Variable lista Shows how the vector remains after the third cycle.

Finally, the data is in order.

2. RESOURCES USED
java
computer
Internet
3. RESULTS

With this program we got a way to ordinate an array of numbers.

Ilustracin 3: insertion sorting algorithm.


The result of the algorithm is successful, since the numbers are from lowest to highest.

Ilustracin 4: desktop test

4. CONCLUSIONS
As a result of the practice performed, it is possible to determine that the insertion
sort method is like imagine that you are playing a card game. Every time a new
card comes out, you have to compare it with the one you have, if it is smaller it
will put it to the left and if it is bigger to the right.
On the other hand this is the idea behind insertion sort. Loop over positions in the
array, starting with index 1. Each new position is like the new card handed to you
by the dealer, and you need to insert it into the correct place in the sorted subarray
to the left of that position.
The realization of the test of desktop allows to clarify and to understand more
thoroughly as is the function of any algorithm, we can see in every iteration of
insertion sort, the movements are made from right to left, all the times will be
necessary.
5. RECOMMENDATIONS
When the class is almost finished, it would be good for the teacher to show us
how the correct algorithm of that practice is.
The learned algorithm should be implemented, in some type of
exercise that requires it.

You might also like