This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Sorting; | |
internal class SortingAlgorithms | |
{ | |
public static int[] BubbleSort(int[] arr) | |
{ | |
int n = arr.Length; | |
for (int i = 0; i < n - 1; i++) | |
{ | |
for (int j = 0; j < n - i - 1; j++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int[] MergeSort(int[] arr, int left, int right) | |
{ | |
if (left < right) | |
{ | |
int mid = (left + right) / 2; | |
MergeSort(arr, left, mid); | |
MergeSort(arr, mid + 1, right); | |
Merge(arr, left, mid, right); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int[] HeapSort(int[] arr) | |
{ | |
int n = arr.Length; | |
for (int i = n / 2 - 1; i >= 0; i--) | |
Heapify(arr, n, i); | |
for (int i = n - 1; i >= 0; i--) | |
{ | |
int temp = arr[0]; | |
arr[0] = arr[i]; | |
arr[i] = temp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int[] InsertionSort(int[] arr) | |
{ | |
int n = arr.Length; | |
for (int i = 1; i < n; ++i) | |
{ | |
int key = arr[i]; | |
int j = i - 1; | |
while (j >= 0 && arr[j] > key) | |
{ | |
arr[j + 1] = arr[j]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int[] QuickSort(int[] arr, int low, int high) | |
{ | |
if (low < high) | |
{ | |
int pi = Partition(arr, low, high); | |
QuickSort(arr, low, pi - 1); | |
QuickSort(arr, pi + 1, high); | |
} | |
return arr; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int[] SelectionSort(int[] arr) | |
{ | |
int n = arr.Length; | |
for (int i = 0; i < n - 1; i++) | |
{ | |
int minIdx = i; | |
for (int j = i + 1; j < n; j++) | |
{ | |
if (arr[j] < arr[minIdx]) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int[] BubbleSort(int[] arr) | |
{ | |
int n = arr.Length; | |
for (int i = 0; i < n - 1; i++) | |
{ | |
for (int j = 0; j < n - i - 1; j++) | |
{ | |
if (arr[j] > arr[j + 1]) | |
{ | |
int temp = arr[j]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using OpenQA.Selenium; | |
public static class HourSelector | |
{ | |
public static (int, int)? SelectHour(IWebElement element, bool isSaturday) | |
{ | |
const string satHour = "08:00 - 09:00"; // Weekends saturday time | |
const string eachHours = "18:30 - 19:30"; // Weekdays time | |
for (int repeater = 0; repeater <= 13; repeater++) // 13 repeater count |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
PhoneFactory pf1 = new PhoneFactory(); | |
pf1.MakePhone(new Iphone()); | |
PhoneFactory pf2 = new PhoneFactory(); | |
pf2.MakePhone(new Samsung()); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PhoneFactory | |
{ | |
public void MakePhone(Phone phone) | |
{ | |
phone.Make(); | |
} | |
} |
NewerOlder