In C, it might not be possible to have function names on left side of an expression, but it’s possible in C++.
Read More »Write a C function that unsets the rightmost set bit of an integer.
Read More »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 and all 2s in last.
Read More »Explain the functionality of below recursive functions.
Read More »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 of the tree are structure wise mirror image of each other. An empty tree is considered as foldable.
Given a linked list, write a function to reverse every k nodes (where k is an input to the function).
Read More »In C, it is never safe to depend on the order of evaluation of side effects. For example, a function call like below may very well behave differently from one compiler to another:
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 two numbers which occur twice. Find the two repeating numbers.
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.
Read More »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) perform poorly, and others (such as heapsort) completely impossible.
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) are identical.
Read More »In C, data type of character constants is int, but in C++, data type of same is char.
Read More »Recursion can be used to do both tasks in one line. Below are one line implementations for stracat() and strcmp().
Read More »Which of the following two code segments is faster? Assume that compiler makes no optimizations.
Read More »Write a SortedMerge() function that takes two lists, each of which is sorted in increasing order, and merges the two together into one list which is in increasing order. SortedMerge() should return the new list.
Read More »Total number of possible Binary Search Trees with n nodes = Catalan number Cn = (2n)!/(n+1)!*n!
Read More »To uniquely construct a Binary Tree, Inorder together with either Postorder or Preorder must be given (See this for details). However, either Postorder or Preorder traversal is sufficient to uniquely construct a Binary Search Tree.
Read More »Predict the output of below C programs.
Read More »Write a function AlternatingSplit() that takes one list and divides up its nodes to make two smaller lists ‘a’ and ‘b’. The sublists should be made from alternating elements in the original list. So if the original list is 0->1->0->1->0->1 then one sublist should be 0->0->0 and the other should be 1->1->1.
Read More »Given a Singly Linked List, starting from the second node delete all alternate nodes of it. For example, if the given linked list is 1->2->3->4->5 then your function should convert it to 1->3->5, and if the given linked list is 1->2->3->4 then convert it to 1->3.
Read More »
