All Hard Articles
The N Queen is the problem of placing N chess queens on an N×N chessboard so that no two queens attack each other. For example,… Read More
Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may… Read More
Given a text txt[0 . . . N-1] and a pattern pat[0 . . . M-1], write a function search(char pat[], char txt[]) that prints… Read More
Given a team of N players. How many minimum games are required to find the second-best player?   We can use adversary arguments based on… Read More
Given an integer array of length N (an arbitrarily large number). How to count number of set bits in the array?The simple approach would be, create an… Read More
Given two strings, string, and pattern, the task is to find the smallest substring in string containing all characters of pattern.  Examples:  Input: string =… Read More
Following questions have been asked in GATE 2011 exam. 1) A max-heap is a heap where the value of each parent is greater than or… Read More
Given below a small piece of code from an open source project, #ifndef __cplusplus    typedef enum BoolenTag {    false,    true } bool;    #endif… Read More
Given a number x, find next number with same number of 1 bits in it’s binary representation.For example, consider x = 12, whose binary representation… Read More
In C, the structures are used as data packs. They don’t provide any data encapsulation or data hiding features. In this article, we will discuss… Read More
We know that the elements in a structure will be stored in sequential order of their declaration. How to extract the displacement of an element… Read More
Merge sort is often preferred for sorting a linked list. The slow random-access performance of a linked list makes some other algorithms (such as quicksort)… Read More
Recursion can be used to do both tasks in one line. Below are one line implementations for stracat() and strcmp(). /* my_strcat(dest, src) copies data… Read More
A quine is a program which prints a copy of its own as the only output. A quine takes no input. Quines are named after… Read More
  Using Morris Traversal, we can traverse the tree without using stack and recursion. The idea of Morris Traversal is based on Threaded Binary Tree.… Read More
We need not to do anything if a number is positive. We want to change only negative numbers. Since negative numbers are stored in 2’s… Read More
Following questions have been asked in GATE CS 2007 exam.  1. Consider a hash table of size seven, with starting index zero, and a hash… Read More
Inversion Count for an array indicates – how far (or close) the array is from being sorted. If the array is already sorted, then the… Read More
Following questions have been asked in GATE CS exam. 1. Consider the following functions Which of the following is true? (GATE CS 2000) (a) h(n)… Read More
Write a function rotate(arr[], d, n) that rotates arr[] of size n by d elements.   Rotation of the above array by 2 will make array… Read More