All Medium Articles

## Merge Sort for Linked Lists 3.5

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 »

## Total number of possible Binary Search Trees and Binary Trees with n keys 3.3

Total number of possible Binary Search Trees with n different keys (countBST(n)) = Catalan number Cn = (2n)! / ((n + 1)! * n!) For… Read More »

## Output of C Programs | Set 14 3.1

Predict the output of below C programs. Question 1 filter_none edit close play_arrow link brightness_4 code #include<stdio.h> int main() {    int a;    char *x;    x… Read More »

## G-Fact 7 3

“Pointer arithmetic and array indexing [that] are equivalent in C, pointers and arrays are different” – Wayne Throop References: http://c-faq.com/aryptr/aryptrequiv.html My Personal Notes arrow_drop_up Save

## Print all combinations of points that can compose a given number 3.3

You can win three kinds of basketball points, 1 point, 2 points, and 3 points. Given a total score n, print out all the combination… Read More »

## Data Structures and Algorithms | Set 24 3.3

Following questions have been asked in GATE CS 2010 exam. 1. The following C function takes a simply-linked list as input argument. It modifies the… Read More »

## Reverse a stack using recursion 3.4

Write a program to reverse a stack using recursion. You are not allowed to use loop constructs like while, for..etc, and you can only use… Read More »

## Construct Tree from given Inorder and Preorder traversals 3.5

Let us consider the below traversals: Inorder sequence: D B E A F C Preorder sequence: A B D E C F Recommended: Please solve… Read More »

## Data Structures and Algorithms | Set 23 3

Following questions have been asked in GATE CS 2005 exam. 1. Which one of the following is a key factor for preferring B-trees to binary… Read More »

## Maximum size square sub-matrix with all 1s 3.3

Given a binary matrix, find out the maximum size square sub-matrix with all 1s. For example, consider the below binary matrix. Recommended: Please solve it… Read More »

## Diameter of a Binary Tree 3.2

The diameter of a tree (sometimes called the width) is the number of nodes on the longest path between two end nodes. The diagram below… Read More »

## Result of sizeof operator 3.7

Predict the output of below program. filter_none edit close play_arrow link brightness_4 code #include <stdio.h> #define TOTAL_ELEMENTS (sizeof(array) / sizeof(array[0])) int array[] = {1, 2,… Read More »

## C Language | Set 6 3.7

Following questions have been asked in GATE CS 2006 exam. 1. Consider the following C-program fragment in which i, j and n are integer variables.… Read More »

## Storage for Strings in C 3

In C, a string can be referred to either using a character pointer or as a character array. Strings as character arrays filter_none edit close… Read More »

## Data Structures and Algorithms | Set 15 3

Following questions have been asked in GATE CS 2008 exam. 1. The most efficient algorithm for finding the number of connected components in an undirected… Read More »

## Data Structures and Algorithms | Set 14 3

Following questions have been asked in GATE CS 2008 exam. 1. We have a binary heap on n elements and wish to insert n more… Read More »

## Data Structures and Algorithms | Set 13 3

Following questions have been asked in GATE CS 2002 exam 1. The number of leaf nodes in a rooted tree of n nodes, with each… Read More »

## Convert an arbitrary Binary Tree to a tree that holds Children Sum Property 3.2

Question: Given an arbitrary binary tree, convert it to a binary tree that holds Children Sum Property. You can only increment data values in any… Read More »

## Output of C Programs | Set 10 3

Predict the output of the below programs. Difficulty Level: Rookie Question 1 filter_none edit close play_arrow link brightness_4 code #include<stdio.h> int main()  {    typedef int… Read More »

## Count Inversions in an array | Set 1 (Using Merge Sort) 3.6

Inversion Count for an array indicates – how far (or close) the array is from being sorted. If array is already sorted then inversion count… Read More »