Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using System.Text;
using System.Collections;
public class MergeSorter
{
public static List<T> MergeSort<T>(List<T> list) where T : IComparable<T>
{
@serkansendur
serkansendur / gist:5693960
Created June 2, 2013 16:09
c# insertion sort
static void InsertSort<T>(T[] array) where T : IComparable<T>
{
int i, j;
for (i = 1; i < array.Length; i++)
{
T value = array[i];
j = i - 1;
while ((j >= 0) && (array[j].CompareTo(value) > 0))
{
@serkansendur
serkansendur / gist:5691737
Created June 1, 2013 21:08
C# bubble and selection sort
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
public class Sorting
{
public static void BubbleSort<T>(T[] input) where T : IComparable<T>
@serkansendur
serkansendur / gist:5687092
Created May 31, 2013 18:51
get permutations of a string
public static void Permute(string str)
{
int length = str.Length;
bool[] used = new bool[length];
StringBuilder output = new StringBuilder();
doPermute(str, output, used, length, 0);
}
public static void doPermute(string input, StringBuilder output,
bool[] used, int length, int level)
@serkansendur
serkansendur / gist:5667374
Created May 29, 2013 01:29
C# BST implementation.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
public class BSTNode<T> where T : IComparable<T>
@serkansendur
serkansendur / gist:5659029
Created May 27, 2013 20:53
c# custom stack implementation. There is already a Stack type in .NET library. Mine is for training purposes.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
@serkansendur
serkansendur / gist:5654944
Created May 27, 2013 02:46
c# linked list implementation for learning purposes. .NET library already has a generic LinkedList type. Mine is just for demonstrating the most common methods that apply to the concept of a linked list.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication3
{
class Program
{