public void setScene2C() { heapsort = new Heapsort(9); list = new int[9]; expectedResult = new int[9]; list[0] = 2; list[1] = 9; list[2] = 1; list[3] = 6; list[4] = 3; list[5] = 7; list[6] = 4; list[7] = 5; list[8] = 8; expectedResult[0] = 1; expectedResult[1] = 2; expectedResult[2] = 3; expectedResult[3] = 4; expectedResult[4] = 5; expectedResult[5] = 6; expectedResult[6] = 7; expectedResult[7] = 8; expectedResult[8] = 9; }
public void HeapSortTest() { int[] op_array = { 3, 5, 7, 1, 3, 12, 56, 8, 7, 16 }; int i; Heapsort h = new Heapsort(op_array); Console.WriteLine("Heap Tree Test\n"); Console.WriteLine("Heap Size {0}", h.HeapSize); h.MaxHeapSort(); }
/// <summary> /// Handles the Click event of the btnFilter control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="RoutedEventArgs"/> instance containing the event data.</param> private void btnFilter_Click(object sender, RoutedEventArgs e) { try { if (selectedCourse == null) { MessageBox.Show("Please select course to filter by grade", "Filter", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (string.IsNullOrWhiteSpace(filterMin.Text)) { MessageBox.Show("Please enter correct Range", "Filter", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (string.IsNullOrWhiteSpace(filterMax.Text)) { MessageBox.Show("Please enter correct Range", "Filter", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } int from = Int32.Parse(filterMin.Text); int to = Int32.Parse(filterMax.Text); var studByCourses = DataManager.StudentsByCourse(Students, selectedCourse.Id); Heap heap = new Heap() { HeapSize = studByCourses.Length, SortedStudent = studByCourses as StudentByCourse[] }; Heapsort hs = new Heapsort(); hs.Sort(studByCourses.Length, heap); var filteredStudents = binarySearch.SearchRange(heap.SortedStudent, from, to); if (filteredStudents == null) { return; } if (filteredStudents.Count == 0) { MessageBox.Show("No student found", "Filter", MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } gridStudents.ItemsSource = filteredStudents; } catch { MessageBox.Show("Error", "Filter", MessageBoxButton.OK, MessageBoxImage.Error); } }
public void Given_UnsortedArray_Expect_SortedArray(int[] d, int[] e) { int[] a = Heapsort.Sort(d); Assert.True(Enumerable.SequenceEqual(a, e)); }
public void Given_NullOrEmptyArray_Expect_ThrowsArgumentException(int[] d) { Assert.Throws <ArgumentException>(() => Heapsort.Sort(d)); }