Thursday, 18 October 2012

AMAZON 2012


AMAZON INTERVIEWS



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...

Saturday, 22 September 2012

Informatica Placement paper 2011


Thursday, November 24, 2011
Informatica Placement paper 2011

we had a placement test of informatica on 24-11-2011.
we have been informed that 2 written tests, 3 to 4 tr rounds, 1 hr round.

two tests have been conducted
1.Objective test: Duration-45min Questions:45

sections:
 Section1:database-20q
 Sections2:operating systems-15q
 Section3:progamming:5q
 Section4:aptitude-5q

negative mark of 0.5 for each wrong answer

section1:

1.pl/sql abbrevation
2.create table as select * from
where "some condition"?
   a.creates a with the rows selected from the

   b.creates a   from
with the empty rows
   c.wrong syntax
3.select dept_no,count(emp_no) from emp GROUPBY dept_no HAVING (emp_no>0)
    a.returns empty rows
    b.returns rows with the dept having atleast 1 employee
    c.query evaluates if the having clause is before groupby
   d.none
4.

section2:
1.'chown' command in UNIX is used to change ........?
2. a directory has files like File1.txt,fIle1.txt,file1.txt,FILE1.txt . Now tha command returns?
  ls -l 'pipe operator' grep -i file*.txt
 a.file1.txt,fIle1.txt
 b.file1.txt
 c.none

3. what does telnet command do?
4.755 permissions to the file indicate user,group,others?
  a. read-write-execute, read-write, read-write
  b. read-write-execute,read-execute,read-execute
  c.none
section3:
 1. what is the output if fn(7) is called?
     fn(int v)
      {
        if(v==1||v==0)
        return 1;
       elseif(v%2==0)
       return fn(v/2)+5;
     else
    return fn(v-1)+3;
     }

2.

section 4:
  1. how many zeroes will be in the product of 1 t0 100 (i.e.,1*2*3*.....*99*100) like in 100  there 2 zeroes?
  a.11
b.17
c.23
d.24
 ans:c
 2. there is some meeting of delegates of some nations.
  they shook hand with each other, except the indian and pakisthani dint shook hands each  other. there are 90 handshakes, then how many delegates are present in the meenting?
a.13
b.14
c.12
d.15
ans: b
3. what is the angle between the minute ahnd nad hour hand when the tym is 3:15 in an  analog clock?



2.subjective test: Questions: 10
   no negative mark
  1. what is the inline function in c++? can we write recursive functions in inline? if we write  recursive functions will the code be compiled without errors?
  2. select * from EMp;
      emp_no           off_no        empname
   -------------------------------------------------------
    312                       12                    james,joe
    312                       12                   jack,hillary
    405                         5                    sunny,michel
    312                       11                    jill,edward


  2.i.   write query to display the duplicate rows?
  2.ii.  write a query to delete ALL tha duplicate rows? (no single row of duplicate row shd b  present)
  2.iii. write a query to delete the duplicate rows leaving one row of duplicate?
  3. write an efficient code to display the unique elemants in the sorted array?
   eg: (1,3,3,3,5,5,5,9,9,9,9)-->(1,3,5,9)
  4. question on Unix command
 5 question on Unix command

GOOGLE PAPER IIT ROORKEE 2011


Friday, November 25, 2011
GOOGLE PAPER IIT ROORKEE 2011


SECTION A
1.       Some problems were given. And they asked that which algorithm strategy (greedy, dynamic programming...) u can apply. Problem name is as-
(i). krushkal algorithm
(ii). Elucid GCD algorithm
(iii). All pair shortest path problem
(iv). Binary search
(v). tower of Hanoi
(vi). Dijakshtra algorithm
(vii). Travelling sales man problem


2.       Some problem is given below. We need to write worst case complexity of best solution for these algorithm-
(i). searching in min heap
(ii). Find top 5 % element in an array
(iii). Find whether two NFA are equivalent
(iv). Find whether two graphs are isomorphic
(v). comparision sorting

3.       Which networking protocol is used for the following
(i). video streaming RTSP
(ii). HTTP
(iii). DNS


SECTION B
Apart from the correctness of the code. We will see that ur code should be modular, easily readable, follow all rule of software engineering-

1.       The anagrams of a set {1, 2, 3 ….n} are the arrangement of the numbers in the set in some order. If we represent each permutation by a signature (string) such that each number in permutation is represented by ‘I’ (increasing) if next number in the sequence is greater than the previous one. otherwise represented by’D’(decreasing). For example- {23416875} is represented by signature “IIDIIDD”. Note that the length of the signature is N-1.
But our task is to do the reverse computing. That is if suppose the signature is given, we need to find the lexicographic minimum permutation of the set if it is there in the set. otherwise return false.
 Vector * permutation (const string &signature);

2.       A set of strings is anagram (permutation) free if no two strings in the set are anagram of each other. Example -‘abab’, ‘abba’,’bbaa’,’baab’ all are anagram of ‘aabb’.
A set of string is given, then write the code to find maximal subset of the given  that is anagram free.


Thought work Coding Round 2011


Thought work Coding Round 2011
 They gave us a program of ipod inventory..the question was..
There is a company which have started selling the ipods ONLINE . But they want to sell these ipods online at best price.
i) They have ipod Inventories at Brazil and Argentina. Each of the inventory can store only 100 ipods.
ii) ipods at Brazil are sold at 100$/unit  and at Argentina they are sold at 50$/unit.
iii) after every order the stock at both brazil and argentina inventories are again back to 100 units.
iv) the no of ipods ordered should be only in multiple of 10.(i.e no of ipods ordered shouldnt be im number like 123 etc. )
v) the order placed should be either fullfilled completely or nothing
vi) if the order is placed like 120 ipods from brazil then the remaining ipods can be brought from the other inventory i.e.argentina.
     but here shipping price of 400$ per 10 units is applied.
they have also given the 4 set of inputs and outputs which your program should produce
:
: :
i) Brazil : 5
    500 : 95 : 100
ii) Brazil : 50
    4500 : 100 : 50
(this trick here is u first have to calculate the cost prize at both brazil and argentina..and d one which is low should be given..here argentina)
iii) Argentina : 120
     7800 : 80 :20
(this was the case where i made a silly mistake...out of 120 only 100 ipods should be sold according to the price at argentina..while reamaining 20 should be sold at prize at brazil which is 100$ + shipping charges (800$))
iv) Argentina : 250
     Out of stock!!!!
this program seems simple..bt the apparoach is important...my friend caluculated it according to country while i first checked the prize and based on that selected a country..
here they will check your code..see the logic. will ask some qstns..and they can also ask to change smthng in your code like prize or amount...they are just checking how logically strong you  are..try and avoid using switch or if else loops..keep it simple and short...

MICROSOFT PLACEMENT PAPERS 2011


microsoft aptitude test 2011
10 MCQ's----------------Time : 30min
1Q.
int rec(int i)
{
static int d=1;
if(i>=5)
return i;
d=d+i;
i=i+i;
rec(d);
}
Find f(1) ?
2Q.
int fun(int j)
{
int i,y;
if(j<5)
return j;
for(i=0;i<3;i++)
y+=fun1(j/3);
return y;
}
int fun1(int k)
{
int i;
if(k<5)
return k;
return 3*fun(k/3);
}
which of the following are correct
a. Recursion never terminates
b.y in fun uses garbage value
c.loop in fun is useless
d. -----
1)a,b,c,d 2)b,c 3)b 4)None
3Q.
Given inorder and postorder for a tree. (.......i forget the exact
nodes....)
Find root and leaf nodes for the tree.
4Q.
#include
main()
{
int a[2][3]= { (1,2,3),(4,5,6)};
int (*ptr)[3] = &a[0];
printf("%d %d\n", (*ptr)[1],(*ptr)[2]);
ptr+=1;
printf("%d %d\n", (*ptr)[1],(*ptr)[2]);
}
what is the output of the program
1.segmentation fault 2.compiler error 3.---- 4.-----------
(----------TWIST:correct answer not given in options,may be they want us to
write the correct answer).
5Q.
In a 4GB addressable system, how much memory the following pointer occupies
in the STACK.
char *p=NULL;
1.4 bytes
2.8 bytes
3.Pointer memory wont be allocated in stack, it will be allocated in heap
4.No memory will be allocated untill it is initialized using malloc()
6Q.
which statement is true about following pointer
char **p=NULL;
1.---------
2.----------
3.No memory will be allocated for *p,p in stack, but memory **p will be
allocated in stack.
4.No memory will be allocated for p in stack, but memory **p,*p will be
allocated in stack.
7Q.
very similar question as 2Q (about static variables).
8Q.
To find the roots for an exp. ax^2 +bx+c=0, a prg. will test following cases
a.if a=0 then roots wont exist
b.if b^2-4ac=0 then single root will exist
c.if b^2-4ac>0 then multiple roots exist
d.if b^2-4ac<0 then imaginary roots exist
certain test cases are given. as
i) a=..,b=..,c=..
ii)a=..,b=..,c=..
iii)..........
iv).......
v)..........
vi)...........
vii)..........
1. (ii,i,iii,iv) 2. (i,iii,iv,vi) 3------- 4---------
We have to find out the minimum test case set from options,which cover all
the four given cases
9Q.
void swap(int a,int b)
{
int t;
t=a;
a=b;
b=t;
return;
}
To swap variables using above function, how the arguments should be passed.
1.swap(x,y)
2.swap(&x,&y);
3.Above swap function cant be used to swap variables
4.None of the above
10Q.
for(x=n,y=-1;x>0;x=x/2,y=y+1);
After the execution of above statement what would y contain
1.f(log(n))
2.f(sqrt(n))
3.f(n)
4.f(nlogn)
WRITTEN TEST -------2 TIME : 45min
1. A string is given such that all characters are in ascending order and
also from [a-z] and the difference between consecutive characters is 1 only,
but one(only one) substring is manipulted in decreasing order. we need to
correct it to ascending order.
Eg: i/p: abcfedgh
o/p: abcdefgh
2.Write test cases for end-to-end functionality in p2p network.
3.Design a file sync system, such that it contain centralized database
server and some files are shared at each client. Change in file at one point
by one client much reflect at all clients. And there may be different files
shared by different clients with server. So, server needs to maintain a
state per client which contain corresponding client files sharing data,etc.
And clients cant be always in online. And sometimes changes made by clients
cant be updated succesfully due to network problems, in those cases
modification shouldn't be done.
Design a system of above features. If u want,you can design a state machine
and specify the transitions clearly to carry out the above functionalit

Wednesday, 19 September 2012

AMAZON CODING ROUND 2011


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

----------------

Directi Placement Paper 2011 NSIT New Delhi


Directi Placement Paper 2011 NSIT New Delhi
1)differnece between HTTP Get and HTTP POST
2) how many BST can be  made from 5 different digit
3)what is minimum time in 2nd maximum number can be found from a given list of n integer.
4)there are five finger in our hand ( thumb,index,middle,ring,little)
if count from thumb as 1 , index as 2 , middle as 3 .....  little as 5 , now going back ring as 6 ,middle as 7 ...thumb as 9 , again going back index as 10 , middle as 11 and so on ,now which is  the 2010th finger.
5) one question is like this i dont remeber properly

main()
{
fork();
fork();
fork();
fork();

}
how many process are there at end.

6)
S(n) is a function. if applied to a number , it sums up all the digits until a single digit is obtained.
  eg: 917=9+1+7=17=8
  if D(n) is the resulting summation number i.e 8 in the above case,
  find how many such numbers exists if 1

7) In how many ways 4 horses can cross the fininsh line .
for example 2 horses can cross in this way : H1 first H2 second , H1 second H2 first,
H1 & H2 both tie.

some question are related to IP address.