Here I post some of the placement questions. These are very simple..
Question 1 : Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ... shows the first 11 ugly numbers. By convention, 1 is included. Write a program to find and print the 1500'th ugly number.
Question 2 : int main()
{
int i, n = 20;
for (i = 0; i < n; i--)
printf("*");
return 0;
}
Change/add only one character and print '*' exactly 20 times.
(there are atleast 3 solutions to this problem)Question 3 : You are provided with two stacks, and pop() and push() functions for them. You have to implement queue i.e. enqueue() and dequeue() using the available operations.
Question 4 : How do you reverse the words in a string? "My name is Ajit Agarwal" to "Agarwal Ajit is name My" A O(n) and 'in space' solution is appreciable.
Question 5 : Given an array of numbers, except for one number all the others, occur twice. Give an algorithm to find that number which occurs only once in the array.
Question 6 : There is a series of numbers in ascending order. All these numbers have the same number of binary 1s in them. Given the number of 1 bits set in the numbers, write an algorithm/C program to find the nth number in the series.
Question 7 : Given a string s1 and a string s2, write a snippet to say whether s2 is a rotation of s1 using only one call to strstr routine? (eg given s1 = ABCD and s2 = CDAB, return true, given s1 = ABCD, and s2 = ACBD , return false)
Question 8 :
What's the  "condition" so that the following code
snippet  prints both HelloWorld !
if  "condition"
printf ("Hello");
else
printf("World");
No comments:
Post a Comment