Sunday, December 2, 2012

Find factorial of a number

Write a program to find factorial of a number both iteratively and recurssively. Write the test cases also.

Remove duplicates from an array and provide test cases

Bit Operations Question

Given a int (16 bit) how would you reverse the bits. (cannot use any BIT operations)

Bit Operations Question

Given two bits A and B. A can 0 or 1, similarly B can be 0 or 1. The various operations that can be performed are OR, AND, XOR etc etc. So the values range from 0000(0) - 1111(15). Write a function which generates 0000-1111 given two bits. Also provide the test cases for same.

Array Question

Write a function that takes an array and pushes all the odd numbers to the front of the array and the even to the back. Give test cases

Fibonacci series

Write a function to generate Fibonacci series with and without recursion. Come up with all the test cases. Walk through the code and explain the benefits of using one over the other (i.e. if you think recursion is good, why?)?

Prime Number Question

Write a function to test whether a given number is prime or not, function signature - int Prime (int x). The code should handle all possible test cases (like string input, buffer overflow, null, etc.). And also the alphabet input should be converted to its corresponding ASCII value and tested whether prime or not?