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 »

#
All Medium Articles

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 »

Print the elements of an array in the decreasing frequency if 2 numbers have same frequency then print the one which came first. Examples: Input:… Read More »

Following questions have been asked in GATE CS 2006 exam. 1. In a binary max heap containing n numbers, the smallest element can be found… Read More »

Algorithm: This method can be derived from (but predates) Newton–Raphson method. 1 Start with an arbitrary positive start value x (the closer to the root,… Read More »

Following questions have been asked in GATE CS exam. 1. Consider the following C function. filter_none edit close play_arrow link brightness_4 code float f(float x,… Read More »

Given an array of positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be… Read More »

A binary search tree (BST) is a node based binary tree data structure which has the following properties. • The left subtree of a node… Read More »

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 x = 5, p… Read More »

Write a function rotate(ar[], d, n) that rotates arr[] of size n by d elements. Rotation of the above array by 2 will make array… Read More »

On some rare machines where branching is expensive, the below obvious approach to find minimum can be slow as it uses branching. filter_none edit close… Read More »

Asked by SG Given an array in which all numbers except two are repeated once. (i.e. we have 2n+2 numbers and n numbers are occurring… Read More »

There are 2 sorted arrays A and B of size n each. Write an algorithm to find the median of the array obtained after merging… Read More »

Following questions have been asked in GATE CS exam. 1. Given the relations employee (name, salary, deptno) and department (deptno, deptname, address) Which of the… Read More »

Following questions have been asked in GATE CS exam. 1. Let S and T be language over ={a,b} represented by the regular expressions (a+b*)* and… Read More »

Asked by Varun Bhatia. Question: Write a code for implementation of doubly linked list with use of single pointer in each node. Solution: This question… Read More »

You are given a Double Link List with one pointer of each node pointing to the next node just like in a single link list.… Read More »

An element in a sorted array can be found in O(log n) time via binary search. But suppose we rotate an ascending order sorted array… Read More »

Given a singly linked list of characters, write a function that returns true if the given list is palindrome, else false. Recommended: Please solve it… Read More »

Lucky numbers are subset of integers. Rather than going into much theory, let us see the process of arriving at lucky numbers, Take the set… Read More »