All Hard Articles
The atomic fetch-and-set x, y instruction unconditionally sets the memory location x to 1 and fetches the old value of x in y without allowing… Read More
Consider the following code fragment: if (fork() == 0) { a = a + 5; printf("%d,%d\n", a, &a); } else { a = a –5;… Read More
Which of the following sorting algorithms can be used to sort a random linked list with minimum time complexity? (A) Insertion Sort (B) Quick Sort… Read More
A ternary search tree is a special trie data structure where the child nodes of a standard trie are ordered as a binary search tree. … Read More
There are two vessels of capacities 'a' and 'b' respectively. We have infinite water supply. Give an efficient algorithm to make exactly 1 litre of water in one of the vessels.
Following is my interview experience for NVIDIA internship. I faced three telephonic rounds in my room. Round 1: Round 1 was a combination of HR… Read More
Team : Transportation Location :Hyderabad Round 1 (Online Test) Q1. Find the kth largest value in a BST Q2. Swap the alternate nodes in a singly linked… Read More
Written Round: 1) Given a binary tree, such that each node contains a number. Find the maximum possible sum in going from one leaf node… Read More
An Optimal Binary Search Tree (OBST), also known as a Weighted Binary Search Tree, is a binary search tree that minimizes the expected search cost.… Read More
There are some glasses with equal capacity as 1 litre. The glasses are kept as follows:  1 2 3 4 5 6 7 8 9… Read More
I am very thankful to geeksforgeeks team for such a great site. I got offer from Amazon. Written Test It was online test on interviewstreet.… Read More
We are given an array of n points in the plane, and the problem is to find out the closest pair of points in the… Read More
Given a graph and a source vertex in the graph, find shortest paths from source to all vertices in the given graph. Dijkstra’s algorithm is… Read More
In my previous post, I have explained about longest increasing sub-sequence (LIS) problem in detail. However, the post only covered code related to querying size of… Read More
We recommend reading the following two posts as a prerequisite to this post. Greedy Algorithms | Set 5 (Prim’s Minimum Spanning Tree (MST)) Graph and its… Read More
Recently I got interviewed at Amazon Hyderabad. I just wanted to share my experience. Hope someone gets little help from this. 1. Telephonic a. In… Read More
Given a stream of numbers, generate a random number from the stream. You are allowed to use only O(1) space and the input is in… Read More
Huffman coding is a lossless data compression algorithm. The idea is to assign variable-length codes to input characters, lengths of the assigned codes are based… Read More
One of the most used optimization techniques in the Linux kernel is ” __builtin_expect”. When working with conditional code (if-else statements), we often know which… Read More
Given an array of words, print all anagrams together. For example, if the given array is {“cat”, “dog”, “tac”, “god”, “act”}, then output may be… Read More