coding questions amazon 2011
They gave to us (NIT CALICUT) this year
here are the coding ques...
1) if there is a singly linked list the we should reverse the list
upto a certain number passed in agrument.
eg..
Node * reverse_upto_num(Node* head, int k)
is the function.. we had to complete it... such tht first K elements
should get reversed.
this is the sample they gave us
1>2->3->4->5 is the list then for k=3.. output should be
3->2->1->5->4
2) for a string we should be able to find all possible permutations of
characters of certain length passed through the function as argument
in lexicographic order.
Permute_string( string, int k)
{
}
eg. if string is : AS and k=2
then function should give following as output.
aa
as
sa
ss
amazon paper internship paper 2012
internship paper-------
amazon paper--
1) WAP for finding first unique character in a given string.
2)WAP for finding if the binary tree given is BST or not.
apti-
1) given post order it was asked which of the option is possible inorder
2) FIFO policy is there and 4 pages can remain in main memory...if
pages are scanned from 1 to 100 and then in reverse order ,than no. of
page faults which occur?
3) given 2's complement of a no. .find the 2's complement of 8*(no.)
4) double power(double base,int exponent)
{
if (exponent==0)
return 1;
else if(exponent%2==0)
power(base*base,exponent/2);
else
power(base*base,exponent/2)*
base;
}
how many multiplications happen for power(5.0,12)?
5) int x=1;
int i=1;
while(x>=1000)
do
x=2x;
i=i+1;
end
find value of i after the loop ends.
6)
#define a 20
void main()
{
printf("%d..",a);
foo();
printf("%d",a);
}
foo()
{
#undef a
#define a 50
}
find output.
7)for n players in chess knockout tournament ,how many matches r
required for determining the winner.
8)question of microprocessor ...details about 3 microprocessor where given..
9)two person 20 miles apart move toward each other at speed of 40
miles/hr and 30 miles/hr. find distance b/w them 1 min before they
collide.
10) a plane fires 4 rockets which has probability of hitting the enemy
as 0.7,0.6,0.4,0.5..
find the probability of hitting the enemy when 4 rockets are shot.
11) one question on when hashing is not a good thing to do...answer
was when range query is there...
No comments:
Post a Comment