Skip to content

C# Examples

  • Home
  • About C#
    • C# Interview Questions and Answers for .NET Developers
    • Learn C#: A Practical Path Through the Examples
  • All Posts
  • Bootstrap 5 Examples
  • Contact

C#

Counting Sort in C#: Linear-Time Sorting for Small Integer Ranges

November 25, 2026July 3, 2014 by turgay

A stable counting sort in modern C# that handles negative numbers, explains the O(n + k) trade-off and guards against ranges too large to count.

Categories C# .NET, Sorting Algorithms Tags C#, counting sort algorithm, counting sort implementation, implementation, sorting algorithm 1 Comment

Bubble Sort in C#: A Generic Implementation with Early Exit

November 25, 2026July 3, 2014 by turgay

Bubble sort in modern C# for any comparable type, with the early-exit check that makes sorted input O(n), plus an honest look at when to use it.

Categories C# .NET, Sorting Algorithms Tags bubble sort algorithm, buble sort implementation, C#, implementation, sorting algorithm Leave a comment

Insertion Sort in C#: A Generic, Span-Based Implementation

November 25, 2026July 3, 2014 by turgay

Insertion sort in modern C# for any comparable type, why it beats quick sort on small or nearly sorted arrays, and where .NET itself uses it.

Categories C# .NET, Sorting Algorithms Tags C#, implementation, insertion sort, insertion sort algorithm, insertion sort implementation, sorting algorithm 2 Comments

Selection Sort in C#: A Generic, Span-Based Implementation

November 25, 2026July 3, 2014 by turgay

Selection sort in modern C# for any comparable type, a fix for a common mistake in older versions, and the one case where it beats other simple sorts.

Categories C# .NET, Sorting Algorithms Tags C#, implementation, selection sort, selection sort algorithm, selection sort implementation, sorting algorithm 3 Comments

Towers of Hanoi in C#: Recursive Solution Explained

November 25, 2026July 3, 2014 by turgay

Solve the Towers of Hanoi puzzle in C# with a short recursive method, see why it needs 2^n – 1 moves, and return the moves as a sequence.

Categories C# .NET Tags C#, hanoi tower, tower of hanoi, tower of hanoi implementation 3 Comments
Older posts
Newer posts
← Previous Page1 … Page7 Page8 Page9 … Page16 Next →

Categories

Recent Posts

  • Select XML Nodes by Name or Attribute Value in C#
  • Binary Search Tree in C#: Add, Find, Remove and Traversals
  • Select, Insert, Update and Delete Data in an Access File with C#
  • C# Collections: Which One to Use and When
  • C# ArrayList vs Generic List: Examples and When to Use Each
  • About
  • Privacy Policy
  • Contact
© 2026 C# Examples