## Data Structures and Algorithms | Set 26

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 »

## fork() and Binary Tree

Given a program on fork() system call. #include <stdio.h> #include <unistd.h> int main() {    fork();    fork() && fork() || fork();    fork();       printf(“forked\n”);    return 0;… Read More »

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

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 »

## Inorder Successor in Binary Search Tree

In Binary Tree, Inorder successor of a node is the next node in Inorder traversal of the Binary Tree. Inorder Successor is NULL for the… Read More »

## CRASH() macro – interpretation

Given below a small piece of code from an open source project, #ifndef __cplusplus    typedef enum BoolenTag {    false,    true } bool;    #endif… Read More »

## puts() vs printf() for printing a string

In C, given a string variable str, which of the following two should be preferred to print it to stdout? 1) puts(str); 2) printf(str); puts()… Read More »

## Next higher number with same number of set bits

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… Read More »

## Applications of tree data structure

Difficulty Level: Rookie Why Tree? Unlike Array and Linked List, which are linear data structures, tree is hierarchical (or non-linear) data structure. One reason to… Read More »

## Output of C++ Program | Set 3

Predict the output of below C++ programs. Question 1 #include<iostream>    using namespace std; class P { public:    void print()    { cout <<” Inside P::”;… Read More »

## Turn an image by 90 degree

Given an image, how will you turn it by 90 degrees? A vague question. Minimize the browser and try your solution before going further. An image can… Read More »

## Which sorting algorithm makes minimum number of memory writes?

Minimizing the number of writes is useful when making writes to some huge data set is very expensive, such as with EEPROMs or Flash memory,… Read More »

## How Linkers Resolve Global Symbols Defined at Multiple Places?

At compile time, the compiler exports each global symbol to the assembler as either strong or weak, and the assembler encodes this information implicitly in… Read More »