Don’t write a copy constructor if shallow copies are ok: In C++, If an object has no pointers or any run time allocation of resource… Read More »
exit() exit() terminates the process normally.
In C, it might not be possible to have function names on left side of an expression, but it’s possible in C++.
Write a program that unsets the rightmost set bit of an integer.
Given an array A consisting 0s, 1s and 2s, write a function that sorts A. The functions should put all 0s first, then all 1s… Read More »
Explain the functionality of below recursive functions.
Question: Given a binary tree, find out if the tree can be folded or not. A tree can be folded if left and right subtrees… Read More »
Given a linked list, write a function to reverse every k nodes (where k is an input to the function).
It is compiler dependent in C. It is never safe to depend on the order of evaluation of side effects. For example, a function call… Read More »
You are given an array of n+2 elements. All elements of the array are in range 1 to n. And all elements occur once except… Read More »
Given an array A, write a function that segregates even and odd numbers. The functions should put all even numbers first, and then odd numbers.
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 »
Two Linked Lists are identical when they have same data and arrangement of data is also same. For example Linked lists a (1->2->3) and b(1->2->3)… Read More »
In C, data type of character constants is int, but in C++, data type of same is char.
Recursion can be used to do both tasks in one line. Below are one line implementations for stracat() and strcmp().