Skip to content

Instantly share code, notes, and snippets.

View hsynkrcf's full-sized avatar
🎯
Focusing

Hüseyin Karacif hsynkrcf

🎯
Focusing
View GitHub Profile
@hsynkrcf
hsynkrcf / SortingAlgorithms.cs
Last active June 21, 2024 01:01
Sorting Algorithms Examples
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++)
@hsynkrcf
hsynkrcf / MergeSort.cs
Created June 21, 2024 00:54
Merge Sort Algorithm Performed On C#
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);
}
@hsynkrcf
hsynkrcf / HeapSort.cs
Created June 21, 2024 00:43
Heap Sort Algorithm Performed On C#
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;
@hsynkrcf
hsynkrcf / InsertionSort.cs
Created June 21, 2024 00:37
Insertion Sort Algorithm Performed On C#
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];
@hsynkrcf
hsynkrcf / QuickSort.cs
Created June 21, 2024 00:26
Quick Sort Algorithm Performed On C#
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;
@hsynkrcf
hsynkrcf / SelectionSort.cs
Last active June 21, 2024 00:38
Selection Sort Algorithm Performed On C#
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])
{
@hsynkrcf
hsynkrcf / BubbleSort.cs
Last active June 21, 2024 00:38
Bubble Sort Algorithm Performed On C#
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];
@hsynkrcf
hsynkrcf / HourSelector.cs
Created February 12, 2024 14:02
Automated Appointment Maker to Spor İstanbul by Selenium
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
@hsynkrcf
hsynkrcf / Program.cs
Created November 10, 2022 00:40
YES OCP
class Program
{
static void Main(string[] args)
{
PhoneFactory pf1 = new PhoneFactory();
pf1.MakePhone(new Iphone());
PhoneFactory pf2 = new PhoneFactory();
pf2.MakePhone(new Samsung());
@hsynkrcf
hsynkrcf / PhoneFactory.cs
Created November 10, 2022 00:34
YES OCP
public class PhoneFactory
{
public void MakePhone(Phone phone)
{
phone.Make();
}
}