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 »

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 »

C Program for Maximum sum rectangle in a 2D matrix | DP-27

Given a 2D array, find the maximum sum subarray in it. For example, in the following 2D array, the maximum sum subarray is highlighted with… Read More »

C Program for efficiently print all prime factors of a given number

Given a number n, write an efficient function to print all prime factors of n. For example, if the input number is 12, then output… Read More »

C Program for Subset Sum Problem | DP-25

Given a set of non-negative integers, and a value sum, determine if there is a subset of the given set with sum equal to given… Read More »