All Easy Articles

## Python Program for KMP Algorithm for Pattern Searching 2

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 »

## Applications of Depth First Search 2.3

Depth-first search (DFS) is an algorithm (or technique) for traversing a graph. Following are the problems that use DFS as a building block. 1) For… Read More »

## Delete nodes which have a greater value on right side 2.5

Given a singly linked list, remove all the nodes which have a greater value on right side. Examples: a) The list 12->15->10->11->5->6->2->3->NULL should be changed… Read More »

## Practice Questions for Recursion | Set 5 2.5

Question 1 Predict the output of following program. What does the following fun() do in general? C++ filter_none edit close play_arrow link brightness_4 code #include… Read More »

## Next Greater Element 2.9

Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element x is the first greater element… Read More »

## Search in a row wise and column wise sorted matrix 2.6

Given an n x n matrix and a number x, find the position of x in the matrix if it is present in it. Otherwise,… Read More »

## fseek() vs rewind() in C 2.5

In C, fseek() should be preferred over rewind(). Note the following text C99 standard: The rewind function sets the file position indicator for the stream… Read More »

## Python Program for n-th Fibonacci number 2.5

In mathematical terms, the sequence Fn of Fibonacci numbers is defined by the recurrence relation Fn = Fn-1 + Fn-2 with seed values F0 =… Read More »

## Python Program for Fibonacci numbers 2

The Fibonacci numbers are the numbers in the following integer sequence.0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ……..In mathematical… Read More »

## Applications of Minimum Spanning Tree Problem 2.2

Minimum Spanning Tree (MST) problem: Given connected graph G with positive edge weights, find a min weight set of edges that connects all of the… Read More »

## Print BST keys in the given range 2.3

Given two values k1 and k2 (where k1 < k2) and a root pointer to a Binary Search Tree. Print all the keys of the… Read More »

## Lower bound for comparison based sorting algorithms 2.4

The problem of sorting can be viewed as following. Input: A sequence of n numbers <a1, a2, . . . , an>. Output: A permutation… Read More »

## Print Ancestors of a given node in Binary Tree 2.5

Given a Binary Tree and a key, write a function that prints all the ancestors of the key in the given binary tree. For example,… Read More »

## Sorted insert for circular linked list 2.2

Difficulty Level: Rookie Write a C function to insert a new value in a sorted Circular Linked List (CLL). For example, if the input CLL… Read More »

## Program to compute Log n 2.3

Write a one line C function that calculates and returns . For example, if n = 64, then your function should return 6, and if… Read More »

## OOD Principles | SOLID 2.3

Object Oriented Programming paradigm deals with centralizing data and associated behaviours in a single entity. The entities will communicate by message passing. The high level… Read More »

## C++ default constructor | Built-in types 2.6

Predict the output of following program? filter_none edit close play_arrow link brightness_4 code #include <iostream> using namespace std;    int main() {       cout <<… Read More »

## Functions that cannot be overloaded in C++ 2.3

In C++, following function declarations cannot be overloaded. 1) Function declarations that differ only in the return type. For example, the following program fails in… Read More »

## C Language | Set 8 2.4

Following questions have been asked in GATE CS 2011 exam. 1) What does the following fragment of C-program print? filter_none edit close play_arrow link brightness_4… Read More »

## return statement vs exit() in main() 2.9

In C++, what is the difference between exit(0) and return 0 ? When exit(0) is used to exit from program, destructors for locally scoped non-static… Read More »