A and B coefficients are given by formulas: B = b and A = exp(a) where:
a= | ![]() |
b= | ![]() |

a= | ![]() |
b= | ![]() |
double sumY = 0; double sumX = 0; double sumXY = 0; double sumX2 = 0; foreach (Sample s in samples) { sumY = sumY + s.y; sumX = sumX + s.x; sumX2 = sumX2 + s.x * s.x; sumXY = sumXY + s.x * s.y; } double a = (sumY * sumX2 - sumX * sumXY) / (samples.Count * sumX2 - (sumX * sumX)); double b = (samples.Count * sumXY - (sumX * sumY)) / (samples.Count * sumX2 - (sumX * sumX));
public IList GnomeSort(IList arrayToSort) { int pos = 1; while (pos < arrayToSort.Count) { if (((IComparable)arrayToSort[pos]).CompareTo(arrayToSort[pos - 1]) >= 0) { pos++; } else { object temp = arrayToSort[pos]; arrayToSort[pos] = arrayToSort[pos - 1]; RedrawItem(pos); arrayToSort[pos - 1] = temp; RedrawItem(pos - 1); RefreshPanel(pnlSamples); if (savePicture) SavePicture(); if (pos > 1) { pos--; } } } return arrayToSort; }
public IList ShellSort(IList arrayToSort) { int i, j, increment; object temp; increment = arrayToSort.Count / 2; while (increment > 0) { for (i = 0; i < arrayToSort.Count; i++) { j = i; temp = arrayToSort[i]; while ((j >= increment) && (((IComparable)arrayToSort[j - increment]).CompareTo(temp) > 0)) { arrayToSort[j] = arrayToSort[j - increment]; RedrawItem(j); pnlSamples.Refresh(); if (chkCreateAnimation.Checked) SavePicture(); j = j - increment; } arrayToSort[j] = temp; RedrawItem(j); pnlSamples.Refresh(); if (chkCreateAnimation.Checked) SavePicture(); } if (increment == 2) increment = 1; else increment = increment * 5 / 11; } return arrayToSort; }
public IList SelectionSort(IList arrayToSort) { int min; for (int i = 0; i < arrayToSort.Count; i++) { min = i; for (int j = i + 1; j < arrayToSort.Count; j++) { if (((IComparable)arrayToSort[j]).CompareTo(arrayToSort[min]) < 0) { min = j; } } object temp = arrayToSort[i]; arrayToSort[i] = arrayToSort[min]; arrayToSort[min] = temp; RedrawItem(i); RedrawItem(min); pnlSamples.Refresh(); if (chkCreateAnimation.Checked) SavePicture(); } return arrayToSort; }
public IList BubbleSort(IList arrayToSort, int left, int right) { for (int i = left; i < right; i++) { for (int j = right; j > i; j--) { if (((IComparable)arrayToSort[j - 1]).CompareTo(arrayToSort[j]) > 0) { object temp = arrayToSort[j - 1]; arrayToSort[j - 1] = arrayToSort[j]; RedrawItem(j-1); arrayToSort[j] = temp; RedrawItem(j); pnlSamples.Refresh(); if (chkCreateAnimation.Checked) SavePicture(); } } } return arrayToSort; } public IList QuickSortWithBubbleSort(IList a, int left, int right) { int i = left; int j = right; if (right - left <= 6) { BubbleSort(a, left, right); return a; } double pivotValue = ((left + right) / 2); int x = (int)a[int.Parse(pivotValue.ToString())]; a[(left + right) / 2] = a[right]; a[right] = x; RedrawItem(right); pnlSamples.Refresh(); if (chkCreateAnimation.Checked) SavePicture(); while (i <= j) { while (((IComparable)a[i]).CompareTo(x) < 0) { i++; } while (((IComparable)x).CompareTo(a[j]) < 0) { j--; } if (i <= j) { object temp = a[i]; a[i++] = a[j]; RedrawItem(i - 1); a[j--] = temp; RedrawItem(j + 1); pnlSamples.Refresh(); if (chkCreateAnimation.Checked) SavePicture(); } } if (left < j) { QuickSortWithBubbleSort(a, left, j); } if (i < right) { QuickSortWithBubbleSort(a, i, right); } return a; }
MCSD | Web Applications |
MCSE | Data Platform |
MCSA | SQL Server 2012 |
MCTS |
.NET Framework 3.5, ASP.NET Applications SQL Server 2008, Database Development SQL Server 2008, Implementation and Maintenance .NET Framework 4, Data Access .NET Framework 4, Service Communication Applications .NET Framework 4, Web Applications |
MCPD |
ASP.NET Developer 3.5 Web Developer 4 |
MCITP |
Database Administrator 2008 Database Developer 2008 |
MS | Programming in HTML5 with JavaScript and CSS3 Specialist |