3.Line Intersection
Problem Description
Suppose you have N number of points in 2D plane.
Identify the straight lines with the given set of points.
You have to find the possible intersection from identified set of lines.
The intersecting lines must not share any common points.
If intersection is possible then return true otherwise false.
Points are always Integer type.
Example:
Suppose the given points[][]={{1,0},{0,1},{1,1},{2,4}},then possible line segments will be:
  
There are no any intersection in the given 2D points,So output will be false.
If the given points[][]={{1,0},{0,1},{1,1},{2,4},{0,0}},then these points will be intersect each other at any points,So the output will be true
Instructions to use Open PBT Client:
- Specify the work directory path in the 'Work Directory Path' field. The path should correspond to your solution work directory.
- Download the Support files by clicking the Get Support Files.
- You will find the problem directories containing:
- problem.h file
- problem.c file
in your work directory.
- Write your solution in .c file
Step 1:
In your Solution File:
Add a function bool intersections(int points[][]).
Step 2:
Pass the following parameter to the function intersections().
- int points[][] :points is a two dimension integer array.
Step 3:
Write the appropriate code to find the subset whose sum is zero based on below given Constraints.
- In this problem you have to find the intersection of lines formed by the given points is possible or not.
- All the points are in 2D plane.
- End point of two intersecting lines should not be common.
- public boolean intersections(int points[][]) will return true when lines will intersect and false when lines doesn't intersect.
- int points[][] is Integer two dimensional array of points in the 2D plane
- If the given points in 2D array is null then return false.
- If intersection is possible then return true otherwise false
The prototype of the function is:
public bool intersections(int points[][])
The function will take a two dimension integer array, which represents the set of points and returns the corresponding boolean value as per the problem statement.
Constraint:
- If the given points in 2Darray is null then return false .
Example 1
Input:
points[][]:
|
{{1,0},{0,1},{1,1},{2,4},{0,0}}
|
Output:
true
Explanation:When we will draw the lines according to given points then they will intersect each other.
Example 2
Input:
points[][]:
|
{{1,0},{0,1},{1,1},{2,4}}
|
Output:
false
For C solutions
Header File :
|
LineIntersection.h
|
File Name :
|
LineIntersection.c
|
Function Name :
|
bool intersections(int points[][]);
|
For C++ solutions
Header File
|
:
|
LineIntersection.h
|
Class Name
|
:
|
LineIntersection
|
Function Name
|
:
|
bool intersections(int points[][]);
|
FileName
|
:
|
LineIntersection.cpp
|
General Instructions
*
|
The file / class names, functions, method signatures, header files to be used are mentioned in the problem statement. Do not use your own names or change the method signatures and fields. You can add any number of additional methods.
|
*
|
Do not forget to mention the file extension, either .c or .cpp as the case maybe.
|
*
|
For C solutions, change the value of "C_OR_CPP" macro in header file to 1 and for C++ solutions change the value to 2.
|
*
|
Incase of iostream.h specify as iostream only.
|
|
Rajesh
7306947200
pedana
krishna dt
|
 |
JOKES CORNER:
Some Good "Poor Jokes"...
Here are some really bad pj's...Read on if u like some...
Lion Roaring...
what happens when the lion roars???
...
TOM & JERRY Begins......
Hights of Optimism:r
Soldier: "Sir we are surrounded by enemies on all sides!!!"
Sardar Major" Excellent!!! we can attack in any direction"
Flirt like this
What is the height of Flirting?
Its When your love letter starts with "TO WHOMSOEVER IT MAY CONCERN"
|
 |
..
BRILLIANT WAYS GIRLS TURN GUYS DOWN!!
HE: I'm a photographer I've been looking for a face like yours!
SHE: I'm a plastic surgeon. I've been looking for a face like yours!!!
HE: May I have the pleasure of this dance?
SHE: No, I'd like to have some pleasure too!!!
the sardar...
Q: Why did the Sardar take a pair binoculars with him to a funeral?
A: It was a distant relative's funeral.
gabbbar...
Gabber: Kitne Aadmi they.
Sambha: Sardar Do,
Gabber: Mujhe ginti nahi aati. Do kitne hotey hain?
Sambha: Sardar Do Ek ke baad aata hai.
Gabber : Aur Do ke pehle?
Sambha: Do ke pehle Ek aata hai.
Gabber: To beech mein kaun aata hai?
Sambha: Beech mein koi nahi aata.
Gabber: To fir Dono ek saath kyon nahi atey?
Sambha: Do Ek ke baad hi aa sakta hai, kyonki Do ek se bada hai.
Gabber: Do ek se bada hai? Kitna bada hai?
Sambha Do ek se Ek bada hai?
Gabber: Agar Do ek se ek bada hai to ek ek se kitna bada hai?
Sambha: Sardar, Maine tumhara namak khaya hai, mujhe goli mar do
ek ladki...
A Lady is standing up on top of the hill and she is going to push her Father down from the hill top.....
SO what is the name of this lady ???
... Well her Name is PUSH-PA!!!!!!!!!!
HE: How did you get to be so beautiful?
SHE: I must have been given your share!!!
HE: Will you come out with me this Saturday?
SHE: Sorry! I'm having a headache this weekend!!!
HE: Go on, don't be shy. Ask me out!
SHE: Okay, get out!!!
HE: I think I could make you very happy
SHE: Why? Are you leaving?
HE: What would you say if I asked u to marry me?
SHE: Nothing. I can't talk and laugh at the same time!!!
HE: Can I have your name?
SHE: Why, don't you already have one?
HE: Shall we go and see a film?
SHE: I've already seen it!!!
HE: Do you think it was fate that brought us together?
SHE: Nah, it was plain bad luck!!!
|
|