In my program, I pick a pivot p from a database S of strings, compute the median r of the distances of the string objects to p and then divide the objects into roughly equal-sized subsets S1 and S2 as follows:

S1={o ε S \{p}|d(p,o)<r} and

S2={o ε S \ {p}|d(p,o)>=r}

where d(p,o) is the distance of the database object o to pivot p.Thus, the objects in S1 are inside the ball of radius r around p, while the objects in S2 are outside this ball. Applying this rule recursively leads to a binary tree,where a pivot object is stored in each internal node, with the left and right subtrees corresponding to the subsets inside and outside the corresponding ball,respectively.

Below I give the function for the above criteria but when I call the function from main, it gives floating point exception. I will really appreciate if someone can help me find the errors in my code and where I am going wrong:

```
void query_ball(TreeNode *t, TreeNode *n,int N)
{
string str;
int *arr=new int[1000];
char *B=new char[40]; // array to store strings from text.txt
char *C=new char[40]; // C is pivot
int v;
vector<string> myStrings(N);
int r,n1,n2;
ifstream file("text.txt"); // this file contains the string objects
for(p=0;p<N;p++)
{
getline(file,str);
strcpy(B,str.c_str());
myStrings[p]=B;
}
int pos=0;
pos=rand()%N;
strcpy(C,myStrings[pos].c_str());
for(p=0;p<N;p++)
{
strcpy(B,myStrings[p].c_str());
arr[p]=edit(B,C); // arr contains the edit distances of the strings to pivot C
//cout<<arr[p]<<endl;
}
n1=N/2;
n2=(N/2)+1;
r=int((arr[n1]+arr[n2])/2); // r is the median of string distances to C
TreeNode *np=new TreeNode;
np->val=C;
if(t==NULL)
t=np;
else
t->np;
for(p=0;p<N;p++)
{
strcpy(B,myStrings[p].c_str());
if(edit(B,C)>=r) // string objects outside ball of radius r
{ n->val=B;
if(t->RChild==NULL)
{
t->RChild=n;}
else
{ query_ball(t->RChild,n,int(N/2));}
}
if(edit(B,C)<r) // string objects inside ball of radius r
{ n->val=B;
if(t->LChild==NULL)
{ t->LChild=n;}
else
{ query_ball(t->LChild,n,int(N/2)); }
}
}
PreOrder(Root);
}
```