Recursive implementation of Insertion Sort

We discussed Insertion sort in detail earlier. This post shows the recursive implementation of Insertion Sort.

Count frequency of a number in a sorted array

Given a sorted array of numbers and a number x, count the number of occurrences of x in the array. Input: int arr[] = {1, […]

Counting Sort

It is used when there are few unique elements in an array. Counting sort takes O(n+k) time in the worst case, where n is number […]

Generic pointers in C language

Generic programming, loosely means that the code we have written is type-independent. It is a larger topic, macros in C language also comes under generic programming. […]

Add sum of all previous elements in array (DPFCI_1.2)

This question is from exercise in my book Dynamic Programming for Coding Interviews (Question: 1.2, Page-5) Question: Given an array, arr of integers, write a […]

Find minimum of 3 numbers without using comparator operator

How will you find minimum of three integers without using any comparison operator ?

Merge two sorted arrays

Given two sorted arrays of size m and n respectively. Also given an empty third array of size (m+n). write code to merge the two […]

Convert a Binary Tree to a Doubly Linked List

The structure of Node of a Binary Tree and Doubly linked list are same. struct Node { int data; Node* left; Node* right; }  Structure […]

Maximum XOR value of two elements

Given an array of numbers find the maximum XOR value of two numbers in the array. Input Array = {12, 15, 5, 1, 7, 9, […]

Print all words in a Trie data structure

Given a collection of words stored in a Trie data structure, write a function that print all the words stored in it. For example, If […]