Exemplo n.º 1
0
 public void printResult()
 {
     int[] arr = new int[] { 12, 11, 13, 5, 6, 7 };
     PrintMethod.printArray1("Marge Sort", arr);
     sort(arr, 0, arr.Length - 1);
     PrintMethod.printArray("Marge Sort", arr);
 }
Exemplo n.º 2
0
        // Selection sort with in List

        public void selectionSortList()
        {
            List <int> list = new List <int> {
                64, 25, 12, 22, 11
            };
            int length = list.Count;

            Console.WriteLine("Before appling Selection Sort :");
            foreach (var item in list)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine("\n");

            for (int i = 0; i < length - 1; i++)
            {
                int minIndex = i;
                for (int j = i + 1; j < length; j++)
                {
                    if (list[j] < list[minIndex])
                    {
                        minIndex = j;
                    }
                }
                int temp = list[minIndex];
                list[minIndex] = list[i];
                list[i]        = temp;
            }
            PrintMethod.printList("Selection Sort", list);
        }
Exemplo n.º 3
0
 public void printResult()
 {
     int[] arr = new int[] { 10, 7, 8, 9, 1, 5 };
     PrintMethod.printArray1("Quick Sort", arr);
     sort(arr, 0, arr.Length - 1);
     PrintMethod.printArray("Quick Sort", arr);
 }
Exemplo n.º 4
0
 public void printResult()
 {
     int[] arr = new int[] { 5, 3, 7, 1, 9, 2, 4, 6, 8 };
     PrintMethod.printArray1("Bubble Sort", arr);
     bubbleSort(arr);
     PrintMethod.printArray("Bubble Sort", arr);
 }
 public AN_Console(System.Windows.Controls.RichTextBox textbox, MainWindow textboxOwner)
 {
     mainWin = textboxOwner;
     Acout = textbox.AppendText;
     Acclear = textbox.Document.Blocks.Clear;
     SetTreeValue();
 }
Exemplo n.º 6
0
        // Selection sort with in array
        public void selectionSortArray()
        {
            int[] arr         = { 64, 25, 12, 22, 11 };
            int   countLength = arr.Length;

            Console.WriteLine("Before appling Selection Sort : ");
            foreach (var item in arr)
            {
                Console.Write(item + " ");
            }
            Console.WriteLine("\n");

            // One by one move boundary of unsorted subarray
            for (int i = 0; i < countLength - 1; i++)
            {
                // Find the minimum element in unsorted array
                int minIndex = i;
                for (int j = i + 1; j < countLength; j++)
                {
                    if (arr[j] < arr[minIndex])
                    {
                        minIndex = j;
                    }
                }
                // Swap the found minimum element with the first
                // element
                int temp = arr[minIndex];
                arr[minIndex] = arr[i];
                arr[i]        = temp;
            }

            PrintMethod.printArray("Selection Sort", arr);
        }
 public AN_Console(System.Windows.Controls.RichTextBox textbox, MainWindow textboxOwner)
 {
     mainWin = textboxOwner;
     Acout   = textbox.AppendText;
     Acclear = textbox.Document.Blocks.Clear;
     main    = new CmdMain();
     main.Main(textbox.AppendText);
 }
Exemplo n.º 8
0
        public void printResult()
        {
            int[] arr = { 2, 4, 5, 3, 1 };
            PrintMethod.printArray1("Stooge Sort", arr);
            stoogesort(arr, 0, arr.Length - 1);

            Console.WriteLine();
            PrintMethod.printArray("Stooge Sort", arr);
            Console.WriteLine();
        }
 public override void Main(PrintMethod p)
 {
     cmds = new CmdNode[] {
         new CmdGet()
     };
     foreach (var item in cmds)
     {
         item.Main(p);
     }
 }
Exemplo n.º 10
0
 virtual public void GetInfo(PrintMethod printMethod)
 {
     try
     {
         printMethod.Invoke(ToString());
     }
     catch
     {
         Console.WriteLine("Your PrintMethos is not valid");
     }
 }
Exemplo n.º 11
0
        public void PrintSurveyData(PrintMethod printMethod)
        {
            printMethod($"**************({this.Id})*{this.Title}*************");
            printMethod($"*             Author: {this.UserCreator.Name}     *");
            printMethod($"===================================================");

            foreach (var question in Questions)
            {
                printMethod($"   ({question.Id})...{question.Title}");
                foreach (var answer in question.Answers)
                {
                    printMethod($"      ({answer.Id})...{answer.Title}...{answer.IsCorrect.ToString()}....{answer.AnswerScore}");
                }
            }
        }
Exemplo n.º 12
0
        public void insertionSort()
        {
            int[] arr         = new int[] { 12, 11, 13, 5, 6 };
            int   lengthCount = arr.Length;

            for (int i = 1; i < lengthCount; ++i)
            {
                int key = arr[i];
                int j   = i - 1;

                /* Move elements of arr[0..i-1], that are
                 * greater than key, to one position ahead
                 * of their current position */
                while (j >= 0 && arr[j] > key)
                {
                    arr[j + 1] = arr[j];
                    j          = j - 1;
                }
                arr[j + 1] = key;
            }
            PrintMethod.printArray("Insertion Sort", arr);
        }
Exemplo n.º 13
0
        public void insertionSortWithList()
        {
            List <int> list = new List <int> {
                12, 11, 13, 5, 6
            };
            int lengthCount = list.Count;

            for (int i = 1; i < lengthCount; ++i)
            {
                int key = list[i];
                int j   = i - 1;

                /* Move elements of arr[0..i-1], that are
                 * greater than key, to one position ahead
                 * of their current position */
                while (j >= 0 && list[j] > key)
                {
                    list[j + 1] = list[j];
                    j           = j - 1;
                }
                list[j + 1] = key;
            }
            PrintMethod.printList("Insertion Sort", list);
        }
 public override void Main(PrintMethod p)
 {
     OutM = p;
 }
Exemplo n.º 15
0
 public static void SetPrint(PrintMethod printMethod)
 {
     Console.Print = printMethod;
 }
Exemplo n.º 16
0
 override public void GetInfo(PrintMethod printMethod)
 {
     printMethod(ToString());
 }
 public abstract void Main(PrintMethod p);