Amazon ML Pyq
Amazon ML Pyq
1. Two squares are chosen at random on a chessboard. What is the probability that
they have a side in common?
- a) 8/13
- b) 17/18
- c) 5/13
- d) 1/18
2. The police plans to enforce speed limits during morning rush hour on four different
routes into the city. The traps on routes A, B, C, and D are operated 40%, 30%, 20%,
and 30% of the time, respectively. Biff always speeds to work, and he has probability
0.2, 0.1, 0.5, and 0.2 of using those routes. What is the probability that he'll get a
ticket on any one morning?
- a) 0.27
- b) 0.93
- c) 0.73
- d) 0.07
4. You have two coins. One of them is fair and comes up heads with probability 1/2
and the other is biased and comes up heads with probability 3/4. You randomly pick
a coin and flip it twice. You get heads both times. What is the probability that you
picked the fair coin?
- a) 13/32
- b) 4/13
- c) 2/13
- d) 19/32
6. The number of solutions for each of the following system of equations is:
\[
2x+y-z=4 \\
x-2y+z=-2 \\
-x+2y-z=-2
\]
- a) 0
- b) 1
- c) Inf
- d) Can't be determined
7. A 3-input neuron has weights 1, 4, and 3. The transfer function is linear with the
constant of proportionality being equal to 3. The inputs are 4, 8, and 5 respectively.
What will be the output?
- a) 51
- b) 153
- c) 54
- d) 160
9. When classifying data with logistic classification, what is the upper bound of the
likelihood in the maximum likelihood method? Is this value attainable?
- a) 1, Yes
- b) e, No
- c) 1, No
- d) 0, Yes
13. Suppose you have a dataset with m=50 examples and n=200000 features for
each example. You want to use multivariate linear regression to fit the parameters Θ
to your data. Should you prefer gradient descent or the normal equation?
- a) Gradient descent, since inverse(XTX) will be very slow to compute in the
normal equation.
- b) Gradient descent, since it will always converge to the optimal Θ.
- c) The normal equation, since it provides an efficient way to directly find the
solution.
- d) The normal equation, since gradient descent might be unable to find the
optimal Θ.
14. The eigenvalues of a 4x4 square matrix having 0's as the diagonal elements and
1's on the off-diagonal elements are:
- a) 2, -2, 0, 0
- b) 1, -1, 1, -1
15. Let A be the 2 x 2 matrix with elements a₁₁ = a₁₂ = a₂₁ = +1 and a₂₂ = -1. Then the
eigenvalues of the matrix A¹⁹ are:
- a) 1024 and -1024
- b) 1024√2 and -1024√2
- c) 4√2 and -4√2
- d) 512√2 and -512√2
18. Assume we are trying to fit the data coming from a cubic function which is
corrupted by standard Gaussian noise, using a linear and 5th-degree polynomial. Let
M₁ and M₅ denote the models corresponding to the linear and 5th-degree polynomial.
Then:
- a) Bias(M₁) ≤ Bias(M₅), Variance(M₁) ≤ Variance(M₅)
- b) Bias(M₁) ≥ Bias(M₅), Variance(M₁) ≤ Variance(M₅)
- c) Bias(M₁) ≤ Bias(M₅), Variance(M₁) ≥ Variance(M₅)
- d) Bias(M₁) ≥ Bias(M₅), Variance(M₁) ≥ Variance(M₅)
1. There are three robots named Ray, Ben, and Kevin. Initially, Ray has a string S of
length N while the other two robots have empty strings. We can make either of the
following moves:
- Move 1: Remove the first character from Ray's string and append it to Ben's
string.
- Move 2: Remove the last character from Ben's string and append it to Kevin's
string.
- You must perform either of the two moves mentioned above in such a way that
the strings left with Ray and Ben are empty and the string left with Kevin is
lexicographically the smallest. Your task is to return this lexicographically smallest
string that Kevin has after completing this activity.
You are required to fill in a function that takes as inputs an integer' input1' (1) <=
input1 <=
1000) and an integer array input2[], containing 'input1'
integers, and returns output1 as the mean, output2 as the median and output3 as the
mode.
The mean and median must be correct to six decimal places.
Mean:
Defined as the average of all numbers in the array
Median:
Defined as the middle element of the array.
Note: For finding the median, elements in the array have to be listed in numerical
order from smallest to largest
Mode:
Defined as the number in the array with the highest frequency.
If many numbers have the same highest frequency, then the mode is calculated by
breaking ties in favour of the smallest of the numbers.
Input Specification:
input1: Integer in the range of 1 <= input1 <= 1000, denoting length of
input array.
input2: Integer input array
Output Specification:
Return output1 (double) variable as the mean
Return output2 (double) variable as the median.
Return output3 (int) variable as the mode.
Example 1:
input1: 3
input2: {1,2,3}
Example 2:
input1: 5
input2: (41,18467,6334,26500,19169}
Output: 14102.200000, 18467.000000, 41
There are N cities in a country. George is initially at the airport in city 1 and he wants
to reach city N. For any city i, there is either a flight to city (i+1) or to (i+3) if it exists.
You have been given an array A with the costs of flight tickets for N cities. To find the
cost of a flight ticket between any two cities i and j, you take the absolute difference
of the costs of those cities in the array A. You can use the formula |a| = |Cost[i] -
Cost[j]] to calculate the cost of a flight ticket, where [al represents the absolute value
of a. Your task is to find and return the minimum possible cost of flight ticket required
to reach the
city N.
Note:
• The number of cities is always greater than 3.
• Assume 1 based indexing.
Input Specification:
input1: An integer value N, representing the number of cities.
input2: An integer array A, representing the cost of tickets to reach the ith a city.
Output Specification:
Return the minimum possible cost of flight ticket required to reach the city N.
Example 1:
input1: 4
input2: (1,4,5,2)
Output: 1
Explanation:
Example 2:
Explanation:
George takes a flight in the below optimal manner: From city 1 to city 2, the cost will
be |4- 12| = 8
• From city 2 to city 3, the cost will be |12-13| = 1
. From city 3 to city 6, the cost will be |13-12| = 1
Therefore, the total cost is 8 + 1 + 1 = 10. Hence, 10 is returned as the output.
The selection test will have two parts – Part A will consist of 20 MCQ on basic
ML concepts and math fundamentals on topics such as probability, statistics
and linear algebra. Part B will consist of two Programming questions. The
overall test duration will be 75 minutes.
The selection test will have two parts – Part A will consist of 20 MCQ on basic
ML concepts and math fundamentals on topics such as probability, statistics
and linear algebra. Part B will consist of two Programming questions. The
overall test duration will be 75 minutes.
Yes, Amazon’s past, current and incoming interns are eligible to participate in
this program.
The program will be spread over eight days July 6, 7, 13, 14, 20, 21, 27 and 28.
Detailed program structure will be shared with selected students.