type your search

Showing posts with label Company papers. Show all posts
Showing posts with label Company papers. Show all posts

Wednesday, January 18, 2012

Amazon Interview Questions -3



1. How would you find the second largest element in an array using minimum no of comparisons?

2. Write a C program for level order traversal of a tree?

3. You are given: 3 types of vehicles: Motorbike, Car, and a special type of car for the handicapped.
3 types of parking: Motorbike parking, Car parking, handicapped car parking.

Motorbikes and cars can only park in their designated parkings, while the handicapped cars can park either in their own parking or the regular car parking.
How would you model this as classes? Explain your methods.


4. Given 2 tables: Employee(Employee_Name,Dept_No) Department(Dept_No, Dept_Name)

Write an SQL query which outputs all the employees, and their department nos and names, including all those departments which have no employees working for them.

6. Explain about Inodes?

7.Give a Linux shell command to find all files in a directory which contain ip addresses.

8. Given a table Employee which has columns name and salary, write an SQL query to find the employee with the second highest salary.

9. Given a table of Player which contains Sno and player name, write a query which finds all possible Table Tennis doubles pairings.

10.Given a string A, and a string B, and a dictionary, how would you convert A to B in the minimum no of operations, given that:

i) All the intermediate words must be from the dictionary

ii) An ‘operation’ is defined as:

a) Delete any character from a string ex dog → do

b) Insert any character into a string ex cat → cart

c) Replace any character in the string with another ex cat → cot

Amazon Intern Interview questions

Amazon Internship Interview Round 1

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

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

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

  4. How do you kill a process?

  5. What is the functionality of a top command?

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

  7. Design a datastructure to represent the movement of a knight on a chess board

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


Click here for the solutions

Amazon Internship Interview Round 2

  1. Why do you like to work with us?

  2. What work are you expecting?

  3. Tell me about any of your experience

Amazon OOPS Interview Questions

Hi Friends,

One of my friend who is working for amazon gave me a good collection of questions which helped him to get into Amazon. I am sharing these questions to help you guys.


  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?

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

  24. What does it mean to declare a...

    * member function as virtual?
    * member function as static?
    * member variable as static?
    * destructor as static?

  25. Can you explain the term "resource acquisition is initialization?"

  26. What is a "pure virtual" member function?

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

  28. What is virtual inheritance?

  29. What is placement new?

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

  31. What is exception handling?

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

  33. What happens if an exception is not caught?

  34. What happens if an exception is throws from an object's constructor?

  35. What happens if an exception is throws from an object's destructor?

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

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

  38. What is a template?

  39. What is partial specialization or template specialization?

  40. How can you force instantiation of a template?

  41. What is an iterator?

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

  43. What is std::auto_ptr?

  44. What is wrong with this statement?
    std::auto_ptr ptr(new char[10]);

  45. It is possible to build a C++ compiler on top of a C compiler. How would you do this?

Basic Questions

* What is a friend, and why do you need it?
* If this doesn't compile, why didn't it (or will it compile?) Don't show comments, which explain the problem.

template  void HashTable <>::dummy()
{
K* k = NULL;
Hashable* h = k; // If this fails to compile, it's because
// K is not derived from Hashable.
}


* This will loop forever. Why? Will it really loop forever? (Answer: Base:func() does not call Base::func(). Base: is just a label, so the line always will call Derived::func() until it runs out of stack space)
class Base {
   public:
       Base() {}
       virtual void func() { /* do something */ }
};

class Derived : public Base {
public:
   Derived() {}
   virtual void func()
   {
Base:func();
/* do something else */
   }
};

main()
{
Derived d;
d.func();    // Never returns!
}


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::operator=(const C &rhs) {
if (this != &rhs) {
   C tmp(rhs);
   this->swap(tmp);
}
return *this;
}
]]

Amazon Interview Questions -2

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.

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.

Wednesday, January 11, 2012

Intel Interview Questions

COMPUTER ARCHITECTURE QUESTIONS

1. For a single computer processor computer system, what is the purpose of a processor cache and describe its operation?

2. Explain the operation considering a two processor computer system with a cache for each processor.
What are the main issues associated with multiprocessor caches and how might you solve it?

3. Explain the difference between write through and write back cache.
4. Are you familiar with the term MESI?
5. Are you familiar with the term snooping?
STATE MACHINE QUESTIONS
1. Describe a finite state machine that will detect three consecutive coin tosses (of one coin) that results in heads.
2. In what cases do you need to double clock a signal before presenting it to a synchronous state machine?
SIGNAL LINE QUESTIONS
1. You have a driver that drives a long signal & connects to an input device. At the input device there is either overshoot,
undershoot or signal threshold violations, what can be done to correct this problem?

VALIDATION QUESTIONS:
What are the total number of lines written in C/C++? What is the most complicated/valuable program written in C/C++?
What compiler was used?
Have you studied busses? What types?
Have you studied pipelining? List the 5 stages of a 5 stage pipeline. Assuming 1 clock per stage, what is the latency of an instruction in a 5 stage machine? What is the throughput of this machine ?
How many bit combinations are there in a byte?
What is the difference between = and == in C?
Are you familiar with VHDL and/or Verilog?
MEMORY, I/O, CLOCK AND POWER QUESTIONS

1. What types of CMOS memories have you designed? What were their size? Speed? Configuration Process technology?

2. What work have you done on full chip Clock and Power distribution? What process technology and budgets were used?


3. What types of I/O have you designed? What were their size? Speed? Configuration? Voltage requirements?


Process technology? What package was used and how did you model the package/system?

What parasitic effects were considered?

4. What types of high speed CMOS circuits have you designed?


5. What transistor level design tools are you proficient with? What types of designs were they used on?


6. What products have you designed which have entered high volume production?

What was your role in the silicon evaluation/product ramp? What tools did you use?

7. If not into production, how far did you follow the design and why did not you see it into production?

Citrix Written Test Questions-1

1. What is the output of this statement ?
Printf(“%d”,printf(“%d %d”,2,2) & printf(“%d %d ”, 2, 2));
a. 22222
b. 22221
c. It will give an error during compilation

2. What is the output of this code snippet
main()
{        int *p[10];
         printf("%d %d\n",sizeof(*p),sizeof(p));
         }
 

3. Function inlining is best used when
a. In a small recursive function
b. In large function where number of variables used is small
c. In a large function where there are many loops and number of variables used is small
d. None of these

4. If there is a large quantum in round robin it will be equivalent to
a. First come first serve
b. Shortest job first
c. Least recently used
d. None of these

5 . which of the following will lead to starvation
a. Fifo
b. Shortest job first
c. Round robin
d. Least recently used

6 . if the address space is 192.168.36.16/28 which of the following is the broadcast ip
a. 192.168.36.0
b. 192.168.36.1
c. 192.168.36.255
d. 192.168.36.31

7. if there are 9 yellow balls, 3 red balls and 2 green balls. What is the probability that the second ball picked is yellow given the first ball is yellow
a. 8/13
b. 9/13
c. 8/14
d. 9/14

8. How many processes are created in this snippet?
Main()
{
Fork();
Fork() && fork () || fork ();
Fork ();
}

a. 15
b. 19
c. 21
d. 27
e. 31

9. which of the following is TRUE about the declaration const char * p
a. the pointer cannot be changed but the value to which it points can be changed
b. the value is constant but the pointer can be changed
c. neither the value nor the pointer can be changed
d. none of these

10. If F and L are the pointers to the first and last elements in a linked list, then which of the following operations is dependent on the length of the list?
a. delete the first element in the list
b. insert a new element as a first element
c. delete the last element of the list
d. add a new element at the end of the list