My teacher wants me to search a typedef struct DATE d
, in a dynamic array using binary search, I have no idea how to do that and I thought the purpose of binary search was to make things simpler and faster, I don't see the point of doing it here ...
Here the typedef struct date
:
typedef struct date { /////////////////////////////////DATE
int year;
int month;
int day;
} DATE;
And the function that I am currently using:
CALENDER_DAY *find_date(int i,ESTUDIO *est,DATE di){// suppose to be with binary search
CALENDER_DAY *pcurrent=est->agenda[i].d; //it finds the calendar where I want to start looking
int size=est->agenda[i].sized; //currently the size is 365 because I started with a year
for (int k =0; k<size ; k++) {
if(pcurrent->d.day==di.day && pcurrent->d.month==di.month && pcurrent->d.year==di.year){
return pcurrent;
}
pcurrent++;
}
//realoc_memory(est,di.year,i);
}