C Program for Tower of Hanoi

Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire… Read More »

C Program to find largest element in an array

Given an array, find the largest element in it. Input : arr[] = {10, 20, 4} Output : 20 Input : arr[] = {20, 10,… Read More »

C/C++ Program to Count trailing zeroes in factorial of a number

Given an integer n, write a function that returns count of trailing zeroes in n!. Examples : Input: n = 5 Output: 1 Factorial of… Read More »

C/C++ Program for nth Catalan Number

Catalan numbers are a sequence of natural numbers that occurs in many interesting counting problems like following. 1) Count the number of expressions containing n… Read More »

C Program for Bubble Sort

Bubble Sort is the simplest sorting algorithm that works by repeatedly swapping the adjacent elements if they are in wrong order. C/C++ filter_none edit close… Read More »

C Program for Bubble Sort on Linked List

Given a singly linked list, sort it using bubble sort. Input : 10->30->20->5 Output : 5->10->20->30 Input : 20->4->3 Output : 3->4->20 filter_none edit close… Read More »

C Program to Swap two Numbers

Given two numbers, write a C program to swap the given numbers. Input : x = 10, y = 20; Output : x = 20,… Read More »

C Program for Selection Sort

The selection sort algorithm sorts an array by repeatedly finding the minimum element (considering ascending order) from unsorted part and putting it at the beginning.… Read More »

C/C++ Program to find sum of elements in a given array

Given an array of integers, find sum of its elements. Examples : Input : arr[] = {1, 2, 3} Output : 6 1 + 2… Read More »

C Program for Binary Search (Recursive and Iterative)

We basically ignore half of the elements just after one comparison. Compare x with the middle element. If x matches with middle element, we return… Read More »

C Program for Radix Sort

The Radix Sort Algorithm 1) Do following for each digit i where i varies from least significant digit to the most significant digit. ………….a) Sort… Read More »

C Program for Counting Sort

Counting sort is a sorting technique based on keys between a specific range. It works by counting the number of objects having distinct key values… Read More »

C Program for Merge Sort

Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merges the… Read More »

C Program for Insertion Sort

Insertion sort is a simple sorting algorithm that works the way we sort playing cards in our hands. filter_none edit close play_arrow link brightness_4 code… Read More »

C Program for Pancake sorting

Given an unsorted array, sort the given array. You are allowed to do only following operation on array. flip(arr, i): Reverse array from 0 to… Read More »