Crossing the Bridge in 17 min, Puzzle
There is a bridge that will collapse in 17 minutes. 4 people (A, B, C and D) are standing on one side of the bridge and want to cross it before it collapses. There are few restrictions, as below: It’s dark, so you can’t cross the bridge without a torch(flashlight), and there is only one […]
Check if a linked list is palindrome
Write a function to check if a Singly linked list is a palindrome or not. For example, the linked list 2 -> 3 -> 4 -> 5 -> 4 -> 3 -> 2 is a palindrome M -> A -> L -> A-> Y -> A -> L -> A -> M is a palindrome […]
Mirror of a Binary Tree
Given a Binary Tree, write a function which will convert that tree to its Mirror Tree. For Example: If the Binary Tree is 1 / \ 2 3 / \ 4 5 Then the Mirror is 1 / \ 3 2 / \ 5 4
Non-leaf nodes of a binary tree
Write a function that will return the number of non-leaf nodes in a binary tree. For example: The below binary tree A / \ B C / \ D E has 3 leaf nodes (C, D & E) and 2 non-leaf nodes(A & B).
Difference between linked list and Arrays
What is the difference between Linked List and Arrays?
Compute polynomial, Cn.x^n + Cn-1.x^(n-1) + … … + C2.x^2 + C1.x + C0
Write an effective algorithm to compute the value of below polynomial for a given value of x : F(x) = Cn.xn + Cn-1.xn-1 + Cn-2.xn-2 + … … + C3.x3 + C2.x2 + C1.x + C0 The normal function to compute this will take O(n2) time. But your algorithm should not take more than O(n) […]
Check if parenthesis are matched or not
Write a function that accepts a string of parenthesis ( ‘(‘ and ‘)‘ characters ) and return true if parenthesis are matched and false otherwise (if the parenthesis are not matched). For example, for the below input Strings, the return values should be as follows: Input String: ( UnMatched Input String: () Matched Input String: […]
Output of a C language Program
What will be the output of the below code in C language: int main () { unsigned int cnt; for (cnt = 5; cnt >= 0; cnt–) printf(“%d “, cnt); }
Print 'Hello World' without using semicolon
Write a program in C language which does not have even a single semicolon, but prints ‘Hello World‘.
Output of C-language code
What will be the output of the below code ? int* myFunc() { int x = 2; return &x; } main() { int* p = myFunc(); printf(“%d”, *p); } No! that the answer if not 2 :).