private void button1_Click(object sender, EventArgs e)
        {
            int[] input = AlgorithmHelper.ConvertCommaSeparetedStringToInt(this.textBox3.Text);

            string output = AlgorithmHelper.ConvertIntArrayToCommaSeparatedString(ShuffleArray(input));

            this.textBox1.Text = output;
        }
        private void button3_Click(object sender, EventArgs e)
        {
            int[]  input  = AlgorithmHelper.ConvertCommaSeparetedStringToInt(this.textBox4.Text);
            int    m      = Convert.ToInt32(this.textBox5.Text);
            string output = AlgorithmHelper.ConvertIntArrayToCommaSeparatedString(GeneratorRandomArrayMethod1(input, m));

            this.textBox2.Text = output;
        }
        private void button2_Click(object sender, EventArgs e)
        {
            int[]  input      = AlgorithmHelper.ConvertCommaSeparetedStringToInt(this.textBox16.Text);
            int    windowsize = Convert.ToInt32(this.textBox1.Text);
            string output     = AlgorithmHelper.ConvertIntArrayToCommaSeparatedString(MaxOfSlidingWindow(input, windowsize));

            this.textBox11.Text = output;
        }
        private void button8_Click(object sender, EventArgs e)
        {
            int[]            input = AlgorithmHelper.ConvertCommaSeparetedStringToInt(this.textBox5.Text);
            int              index = Convert.ToInt32(this.textBox8.Text);
            int              value = Convert.ToInt32(this.textBox9.Text);
            SegmentationTree tree  = new SegmentationTree(input);

            tree.UpdateValueAtindex(index, value);
            this.textBox5.Text = AlgorithmHelper.ConvertIntArrayToCommaSeparatedString(tree.InputArray);
        }
Ejemplo n.º 5
0
        private void button6_Click(object sender, EventArgs e)
        {
            int[] input1 = AlgorithmHelper.ConvertCommaSeparetedStringToInt(this.textBox7.Text);
            int[] input2 = AlgorithmHelper.ConvertCommaSeparetedStringToInt(this.textBox5.Text);

            int[] input = new int[input1.Length + input2.Length];
            Array.Copy(input1, input, input1.Length);
            Array.Copy(input2, 0, input, input1.Length, input2.Length);
            Array.Sort(input);

            int[] noncommon = ArrayHelper.GetNonCommonItemsInSortedArray(input);

            string output = AlgorithmHelper.ConvertIntArrayToCommaSeparatedString(noncommon);

            this.textBox9.Text = output;
        }
        private void button5_Click(object sender, EventArgs e)
        {
            int[] input = AlgorithmHelper.ConvertCommaSeparetedStringToInt(this.textBox4.Text);

            int[]   output = new int[input.Length];
            AVLTree tree   = new AVLTree();

            for (int i = input.Length - 1; i >= 0; i--)
            {
                int counter = 0;
                tree.Root = tree.Insert(tree.Root, input[i], ref counter);
                output[i] = counter;
            }


            this.textBox3.Text = AlgorithmHelper.ConvertIntArrayToCommaSeparatedString(output);
        }
        private void button10_Click(object sender, EventArgs e)
        {
            int[] input = AlgorithmHelper.ConvertCommaSeparetedStringToInt(this.textBox12.Text);

            //http://stackoverflow.com/questions/15197058/number-of-distinct-smaller-elements-on-left-for-each-position-in-a-array
            //eg For the array 1 1 2 4 5 3 6 the the answer would be 0 0 1 2 3 2 5
            //The same as above problem but insert from left to right
            int[]   output = new int[input.Length];
            AVLTree tree   = new AVLTree();

            for (int i = 0; i < input.Length; i++)
            {
                int counter = 0;
                tree.Root = tree.Insert(tree.Root, input[i], ref counter);
                output[i] = counter;
            }


            this.textBox10.Text = AlgorithmHelper.ConvertIntArrayToCommaSeparatedString(output);
        }
        private void button4_Click(object sender, EventArgs e)
        {
            int[] input = AlgorithmHelper.ConvertCommaSeparetedStringToInt(this.textBox4.Text);

            this.textBox3.Text = AlgorithmHelper.ConvertIntArrayToCommaSeparatedString(ConstructSmallerElements(input));
        }