Amdocs Interview Question for Software Engineers


Team: Java
Country: United States
Interview Type: Written Test




Comment hidden because of low score. Click to expand.
0
of 0 vote

I would propose the following pseudo code:

Define number 'nIter' - number of border points you want to plot
Define your plotting accuracy 'eps'
Initialize shape list  	// it will contain shape border points to plot
3. Find point x0 labelled as '0' - inside, via random sampling
4. while (nIter not exceeded) {
 	Find point x1 labelled as '1' - outside via random sampling
	Connect the points x0, x1 by a line
 	Compute the unit vector of this line
 	Perform a binary search in order to find a breakpoint x_br
	such taht: isBounded(x_br) == 0 and isBounded(x_br+eps*unit vector) == 1
 	Add x_br to the list
 	x0 = x_br
}
5. Plot the shape list points on the screen.

Hope this make sense. I am looking forward for some more exciting solutions :)

- autoboli February 20, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

{
import java.util.Scanner;

class Shape{
	int shapeX=200;
	int shapeY=300;
	
	public void isBounded(int x,int y){
		if(x<shapeX && y<shapeY){
			System.out.println("Both points lie inside shape");
		}else if(x>shapeX && y>shapeY){
			System.out.println("Both points lie outside shape");
		}else if(x==shapeX && y==shapeY){
			System.out.println("Both points lie on the shape");
		}
		else{
			if(x>=shapeX && y<shapeY){
				System.out.println("Point x lies outside shape && point y lies inside shape");
			}else if(x>=shapeX && y==shapeY){
				System.out.println("Point x lies outside shape && point y lies on shape");
			}else if(x<=shapeX && y>=shapeY){
				System.out.println("Point x lies inside shape && point y lies outside shape");
			}else if(x==shapeX && y>=shapeY){
				System.out.println("Point x lies on shape && point y lies outside shape");
			}
		}
	}
}

public class BoundaryConditions {

	public static void main(String[] args) {
			Shape shape=new Shape();
			Scanner sc=new Scanner(System.in);
			int x=sc.nextInt();
			int y=sc.nextInt();
			shape.isBounded(x, y);
	}

}

}

Is this code correct solution?

- Vishal Asrani October 08, 2016 | Flag Reply


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More