Amazon Whole-Testpaper Amazon new placement papers

Posted 4 weeks ago
Posted By Govt Jobs Today

Written Test has 2 Sections A, B
In Section A there were 20 Questions:
Technical Questions :15
Aptitude:5
Time Limit  :30 min
Small Answer Type
Multiple choice
Aptitude-5
The first round was online. It had 20 mcq’s and 2 code’s.MCQ’s where quite simple, it had 15 tech. and 5 apti. Technical where easy it had q’s on finding the o/p,complexity,and more importance was in DS, and especially TREE.

 

The two coding q’s where as below.

1)      Finding all possible UNIQUE substings of and array of char. And displaying it in sorted order.

 

2)      It was on tree was easy. I don’t remember the exact question.

 

Some Sample Questions

 

1.Two tables emp(empid,name,deptid,sal) and dept(deptid,deptname) are there.write a query which displays empname,corresponding deptname also display those employee names who donot belong to any dept.

 

2.Display the employees whose salary is less than average salary.

 

3.what is the output of the program
main()
{
int c=5;
printf(“%d %d %d”,c,c<<2,c>> 2);
}

 

4.
main()
{
int a[8][10],c=0,i,j;
for(i=0;i<10;
i++) for(j=0;
j<8;j++) a[j][i]=c++;
printf(“%d”,a[3][6]);
}

 

5.What is the wrong in this program
main()
{
char *p,*q;
p=(char *)malloc(25);
q=(char*) malloc(25);
strcpy(p,”amazon” );
strcpy(q,”hyd”);
strcat(p,q);
printf(“%s”,p);
}

 

6.write prefix and post fix notation for (a+b)*c-(d+e)^(f-g)

 

7.what is the output of the program
main()
{
int i=5;
printf(“%d”,fun(fun(fun(fun( fun(i))))));
}
void fun(int i)
{ if(i%2) return (i+(7*4)-(5/2)+(2*2));
else return (i+(17/5)-(34/15)+(5/2));
}

8.When it is always true boolean fun

(node *p)
{
return ((p==null)||(p->next==null)|| (p->info<=p->next->info)&&( fun(p->next)));
}

a)when list is empty or has one node
b)when the ele are sorted in non decreasing order
c)when the ele are sorted in non increasing order

 

9.what is x here (x&&!(x&(x-1))==1)
a)x is always a prime
b)x is a power of 2
c)x is even d)x is odd

 

10 .What is the difference between deep copy and shallow copy

 

11.In java what is the difference between sleep() and wait() .

 

12.What happens when the parent process of a child process exits before the child ?

 

13.There are three persons A,B,C .A shots the target 6 times out of 7 shots .B shots 4 out of 5 shots .Then what is the probability of hitting the target twice when 2 persons are selected at random.

 

14.what is valid in cpp char *cp; const char *cpp; 1) cpp=cp; 2) cp=cpp;

 

15.write program to swap 2 variables without using extra memory.

 

16.write a shell command to find all java files present in nested directories.

 

17.There are 6 pairs of black socks and 6 pairs of white socks. What is the probability to pick a pair of black or white socks when 2 socks are selected randomly in darkness.

 

18.A string of alphanumeric is there. Find a string that starts with b and ends with 3 characters. section B (we have to write programs) time:30 min

 

1.There is a sorted array which is of very large size.In that all except one no. are repeated once.How to find that non repeated no.

2.There are 2 linked lists.Those 2 lists are meeting at a point. How to find that meeting point.

 

Latest Amazon Interview Questions -1

1. How do you convert a decimal number to its hexa-decimal equivalent.Give a C code to do the same

2. Explain polymorphism citing an example.

3. What are the 4 basics of OOP?

4. Define Data Abstraction. What is its importance?

5. Given an array all of whose elements are positive numbers, find the maximum sum of a subsequence with the constraint that no 2 numbers in the sequence should be adjacent in the array.
Eg.
i) 3 2 7 10 should return 13 (sum of 3 and 10)
ii) 3 2 5 10 7 should return 15 (sum of 3, 5 and 7)

6. Given a Binary Search Tree, write a program to print the kth smallest element without using any static/global variable. You can’t pass the value k to any function also.

7.You are given some denominations of coins in an array (int denom[])and infinite supply of all of them. Given an amount (int amount), find the minimum number of coins required to get the exact amount. What is the method called?

8.Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 1 number. Find the missing number.

9.Given an array of size n. It contains numbers in the range 1 to n. Each number is present at least once except for 2 numbers. Find the missing numbers.

10.Given an array of size n. It contains numbers in the range 1 to n. Find the numbers which aren’t present.

1.Given a string,find the first un-repeated character in it? Give some test cases

2.You are given a dictionary of all valid words. You have the following 3 operations permitted on a word:
a) Delete a character
b) Insert a character
c) Replace a character
Now given two words – word1 and word2 – find the minimum number of steps required to convert word1 to word2. (one operation counts as 1 step.)

3.Given a cube of size n*n*n (i.e made up of n^3 smaller cubes), find the number of smaller cubes on the surface. Extend this to k-dimension.

4.What is a C array and illustrate the how is it different from a list.

5. What is the time and space complexities of merge sort and when is it preferred over quick sort?

6. Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.

7. Given n red balls and m blue balls and some containers, how would you distribute those balls among the containers such that the probability of picking a red ball is maximized, assuming that the user randomly chooses a container and then randomly picks a ball from that.

8.Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.

9. Given an array of size n ,containing every element from 1 to n+1, except one. Find the missing element.

 

10 There are two urns A and B and an equal number of red balls and blue balls.How do u place the balls in the urns such that the probability of picking up the red ball is greater?

11 Two trains enter at the opposite sides of a tunnel of length L with speeds ‘V’. A particle enters the tunnel at the same time with a speed ‘v’ and it vibrates in the tunnel[i.e. if it reaches the end of the tunnel then it comes back]. What is the position of the particle by the time the 2 trains meet?

12 Write an sql query to sort a table according to the amounts in a row and find the second largest amount.

13 How do you kill a process?

14 What is the functionality of a top command?

15 Given an array of size n+1 which contains all the numbers from 1 to n.Find the number which is repeated in O(n) time .How do you proceed with the same with floating numbers

from 0 to 1 instead of 1 to n?

16 Design a data structure to represent the movement of a knight on a chess board

17 Write an algorithm to traverse a knight covering all the squares on a chessboard starting at a particular point.

18)Place a red ball in a urn and all the further balls in the other urn.The probability for picking out the red ball is now greater than 0.5.
19)If v<=2V then the position is (v*L)/(2*V) from the starting point else it is 2*L -(v*L)/(2*V) from the starting point.

20If we know the process then we can kill it by killall -9 “process name” else we can kill it using its process id obtained by the command ps -x by kill -9 “processid” .

21Top command displays all the Linux tasks running at that particular time.It provides their running time and the resources used.

22The number appearing 2 times is (sum of all the numbers in the array) – (sum of the numbers from 1 to n).
For floating numbers multiply it with 100 and proceed.

 

Amazon OOPS Interview Questions

1.       What are the major differences between C and C++?

 

2.       What are the differences between new and malloc?

 

3.       What is the difference between delete and delete[?

 

4.       What are the differences between a struct in C and in C++?

 

5.       What are the advantages/disadvantages of using #define?

 

6.       What are the advantages/disadvantages of using inline and const?

 

7.       What is the difference between a pointer and a reference?

 

8.       When would you use a pointer? A reference?

 

9.       What does it mean to take the address of a reference?

 

10.   What does it mean to declare a function or variable as static?

 

11.   What is the order of initialization for data?

 

12.   What is name mangling/name decoration?

 

13.   What kind of problems does name mangling cause?

 

14.   How do you work around them?

 

15.   What is a class?

 

16.   What are the differences between a struct and a class in C++?

 

 

17.   What is the difference between public, private, protected, and friend access?

 

18.   For class CFoo { }; what default methods will the compiler generate for you>?

 

19.   How can you force the compiler to not generate them?

 

20.   What is the purpose of a constructor? Destructor?

 

21.   What is a constructor initializer list?

 

22.   When must you use a constructor initializer list?

What is a:
* Constructor?
* Destructor?
* Default constructor?
* Copy constructor?
* Conversion constructor?

What does it mean to declare a…
* member function as virtual?
* member function as static?
* member variable as static?
* destructor as static?

 

1.Can you explain the term “resource acquisition is initialization?”

 

2.What is a “pure virtual” member function?

 

3.What is the difference between public, private, and protected inheritance?

 

4.What is virtual inheritance?

 

5.What is placement new?

 

6.What is the difference between operator new and the new operator?

 

7.What is exception handling?

8.Explain what happens when an exception is thrown in C++.

9.What happens if an exception is not caught?

10.What happens if an exception is throws from an object’s constructor?

11.What happens if an exception is throws from an object’s destructor?

 

12.What are the costs and benefits of using exceptions?

13.When would you choose to return an error code rather than throw an exception?

14.What is a template?

15.What is partial specialization or template specialization?

16.How can you force instantiation of a template?

17.What is an iterator?

18.What is an algorithm (in terms of the STL/C++ standard library)?

19.What is std::auto_ptr?

20What is wrong with this statement?

std::auto_ptr ptr(new char[10]);
It is possible to build a C++ compiler on top of a C compiler. How would you do this?
More advanced questions:

* What is a vtbl ?

* What is RTTI and why do you need it?

* How do I specialize a template? Give an example.

To separate sheep from goats (for those claiming C++ Guru status):

* What is a partial template? Why would you use one?

* How to I create a binary functor in the STL?

Given the following code:
class A;
class B;
class C {
A* a_;
B* b_;
public:
};

*Implement a copy constructor and assignment operator for C. A sample solution is something like:
class C {
A* a_;
B* b_;
void swap(C& rhs) { rhs.a_ = a_; rhs.b_ = b_; }
public:
C(const C& rhs) {
auto_ptr<> a(new A(rhs.a_));
auto_ptr<> b(new B(rhs.b_)):
delete a_;
delete b_;
a_ = a.release();
b_ = b.release();
}
C& operator=(const C& rhs) {
C temp(rhs);
temp.swap(*this);
return *this;
}
};

What is wrong with this class, assuming that this is its complete interface?

class C {
char *p;
public:
C() { p = new char[64]; strcpy(p, “Hello world”); }
~C() { delete p; }
void foo() { cout << “My ptr is: ‘” << p << “‘” << endl; }
};

Since this has an overtly programmed destructor, the member wise semantics for destruction are not good enough; therefore, they are not good enough for copy and assignment either. But, the copy ctor and op= are not programmed, so we will have some serious trouble.
Gradual hinting: what happens when we make a copy? [correct answer: pointer is copied]. Now, the original goes out of scope, what happens to the copy? [pointer dangles]. How would you fix it?
[also, that delete p should be delete[ p since p was allocated with the array new]
Assuming that swap() and copy construction are part of your interface for class C, what’s the cookie-cutter pattern for operator= that uses them?
answer:

C& C:perator=(const C &rhs) {
if (this != &rhs) {
C tmp(rhs);
this->swap(tmp);
}
return *this;
}
]]

 

 

There were two subjective questions

1. The first one was “given two lists write a function which returns a list which is the intersection of the two lists.the original lists should remain same.
(Intersection – if first list is say,1,20 3,45 and second list is 3,24 ,45,90,68 then intersection should be 3,45 )

2. The second was given two nodes of a binary tree find the closest ancestor of the two nodes.
Note:consider binary tree and binary search tree also.

In short answer type questions, the questions were

1.There was an aptitude’s question in which P(A) and P(B) were given and we had to find P(B/A) and P(A/B) when A and B are independent events.

2.What is the probability that the the 4 digit’s no. which is formed by using the digits 1,2,3,4,5,6 is divisible by 4.

3.What tree traversal gives the no. in sorted order.Inorder,preorder or postorder ?

4.Preorder and inorder traversal was given and we had to find the tree.

Amazon  Interview questions

1.      Write an algorithm to determine if 2 linked lists intersect

2.      Find the 2nd-largest node in a binary tree

3.      Probably the most difficult question they asked me was, he put a binary tree on the whiteboard and I had to write a function that would find if the tree was symmetrical or not. Anyone who’s familiar with data structures and recursion should be fine with this, just don’t freak out when they propose the question.

4.      Find the element from the array that has odd number of occurences

5.      Generate words from a n *n matrix

6.      How would you, specifically, build Amazon Web Services?

In an Amazon Fulfillment center, it takes a quality specialist 20 minutes to perform a damage-free check of one laptop. A temporary contractor takes 60 minutes to perform the same task.

 

1How many hours does it take a quality specialist and a temporary contractor together to perform a damage-free check of a batch of 160 laptops?

135 hours                      40 hours                         60 hours                                     24 hours

2An space rocket travels around the Earth at a speed of approximately 18.5 miles per second. This approximate speed is how many miles per hour?

1,080                           1,16064,                              80066,                                           600

3If x-4 is 6 more than y, then x+9 is how much more than y+5?

10                                  12                                     14                                                    17

4The first generation of the Galaxy 1 smartphone used to have a battery life of 20 hours. The new Galaxy 2 has smaller batteries with 40% less capacity. Also, the operating system of the Galaxy 2 consumes on average 50% less battery than the one of Galaxy 1. What is the battery life of Galaxy 2?

24 hours                      26 hours                                 30 hours                                      36 hours

5Exactly 1/5 of the clients who entered Mike’s shop yesterday were women. If exactly one third of the women were blonde, what is the minimum possible number of clients that entered the shop yesterday?

 

6Amazon.it had 140 thousand visits on Friday, including new and returning visitors. Statistics show that for 5 new visitors there were 3 returning visitors (ratio of 5:3). What was the difference between new visitors and returning visitors on Friday?

15 thousand                    25 thousand                        35 thousand                                   75 thousand

7Amazon is negotiating with a carrier (SEUR) that will ship products from Amazon’s wharehouse in Madrid to clients within the same city. SEUR charges Amazon per shipment based on the DISTANCE between Amazon’s wharehouse to the client’s address – €2 fixed for the first 2 kilometers and €0.5 per additional kilometer (measured by the meter, not by whole kilometers) for each delivery within a given city. 20% of clients live within 2 kilometers of Amazon’s wharehouse in Madrid – on average they live 1 km away. If all Amazon’s clients in Madrid live on average 4.5 kilometers away from Amazon’s wharehouse, what is the estimated average shipping cost per delivery in Madrid, with SEUR?

8A supplier of Amazon increases the price of a Book “Cooking for Children”) by 30% from last year and Amazon has planned to acquire additional stock with total (cost) value of 10,5% higher than last year’s stock acquisition. , By what % should Amazon  reduce the quantity of “Cooking for Children” books that will buys,with regards to last year?

19.5%                               12%                                    8%

There are ONLY 3 brands of video consoles (A, B and C). In 2010 A and B together represented 50% of units sold. C sold 3 million more units than A. Also, C sold 2.5 times the same units sold by B. If all video consoles had the same price of €300, what was the total video console market value in 2010?

Three years ago, a son was 25 years younger than his father. At present the father is 6 times as old as the son. How old will the son be three years from now?

5                                     9                                            8                                             11

5                                 10                                            15                                                 20