julio 02, 2014

Algoritmo Burbuja - Bubble Sort

El algoritmo de la burbuja tiene como objetivo ordenar una lista de elementos contenidos en un arreglo... y es la forma mas intiuitiva de hacerlo.

Los pasos para hacerlo son los siguientes:
1. Recorrer todo el arreglo con una sentencia iterativa (for, while, do/while)
2. Comparar el elemento i con el elemento i+1
3. Si por alguna razon el elemento i+1 contiene un valor menor al elemento i, se intercambian.
4. Si recorres el arreglo una vez con estas condiciones, el ultimo elemento será el mayor de todos... magia?
5. Por lo tanto hay que recorrer el elemento tantas veces como elementos haya en el arreglo para que se acomoden todos.

y ahora el algoritmo:

sea Arreglo un arreglo de enteros desordenados

for(int iI = 0; iI < Arreglo.length; iI++)
{
    for(int iJ = 0; iJ < Arreglo.length; iJ++)
    {
         if(Arreglo[iJ] < Arreglo[iJ+1])
        {
            Auxiliar = Arreglo[iJ];
            Arreglo[iJ] = Arreglo[iJ+1];
            Arreglo[iJ+1] = Auxiliar;
        }
    }
}

y es todo :P

junio 07, 2011

Silverlight dynamic panel component

Well this component is not mine... I downloaded it from a webpage but it was very hard to find it... it seems like codeplex doesn't have it anymore...

Download DLL

The trick is...
adding this to your xmlns lines...

xmlns:blackcontrols="clr-namespace:Blacklight.Controls;assembly=Blacklight.Controls"

and this to your layout...

<blackcontrols:DragDockPanelHost x:Name="MainContainer"
                                         VerticalAlignment="Stretch"
                                         HorizontalAlignment="Stretch"
                                         Background="Transparent"
                                         MinimizedPosition="Bottom" />

Then in your code behind, you'll need to create as many panels as you need... here is an example of what I added...

this goes in your using section....
       using BIOnline.Components.DataComponents;

this is what actually creates panels...

            Blacklight.Controls.DragDockPanel Panel1 = new Blacklight.Controls.DragDockPanel();
            Blacklight.Controls.DragDockPanel Panel2 = new Blacklight.Controls.DragDockPanel();
            Blacklight.Controls.DragDockPanel Panel3 = new Blacklight.Controls.DragDockPanel();
            Panel1.Header = "Hours by Team";
            Panel2.Header = "Indirect Hours by Team";
            Panel3.Header = "Employees";
            MainContainer.Items.Add(Panel1);
            MainContainer.Items.Add(Panel2);
            MainContainer.Items.Add(Panel3);


and that's it... any comments????

Welcome everybody

this entry is just welcoming everyone who is interested in reading or sharing important information about... not geek things... but very useful coding advise, or a very special knack... well feel free to email me whenever you want to publish something... I'll do it from time to time when I have something important to say... read you then!!