Work in HR or Recruiting?
Amazon.com
www.amazon.com Seattle, WA 5000+ Employees
Work in HR? Complete Your Profile

612 interview experiences Back to all Amazon.com Interview Questions & Reviews

Interview Question for Software Engineer at Amazon.com:
Jul 28, 2012

3 - design amazon product recommendation system


Add Tags [?]

See more for this Amazon.com Software Engineer Interview

Helpful Question?  
Yes | No
Inappropriate?

Answers & Comments (1)

Oct 19, 2012

by Ozan Eren Bilgen:

Here is the division:

    public static double division(double a, double b) throws Exception
    {
        double epsilon = Double.MIN_NORMAL;
        double step = 1.0;
        double result = 0;
        double temp;
        double sign = 1;
        if (b == 0)
        {
            throw new Exception("Division by zero!");
        }
        if (a < 0)
        {
            a *= -1;
            if (b < 0)
            {
                b *= -1;
            }
            else
            {
                sign = -1;
            }
        }
        if (b < 0)
        {
            b *= -1;
            sign = -1;
        }
        while (step > epsilon)
        {
            temp = result * b;
            if (temp == a)
            {
                break;
            }
            else if (temp > a)
            {
                result -= step;
                step *= 0.1;
                result += step;
            }
            else
            {
                result += step;
            }
        }
        return result * sign;
    }
Helpful Answer?  
Yes | No
Inappropriate?

To comment on this question, Sign In with Facebook or Sign Up

Amazon.com – Why Work for Us?

At Amazon, we believe that everyone is a leader—it's part of what makes us 100% Peculiar. Whether you are a Software Development Engineer, Product Manager, Fulfillment Associate, or Customer Service Representative, you… Full Overview

Provided by employer [?]

Tags are like keywords that help categorize interview questions that have something in common.