void time_search_i(Item *items, size_t len, int key) { struct timespec start, end; long long t; int i; clock_gettime(CLOCK_ID, &start); for (i = 0;i < N;i++) { search_i(items, len, key); } clock_gettime(CLOCK_ID, &end); t = ((end.tv_sec - start.tv_sec) * 1000000000) + end.tv_nsec - start.tv_nsec; printf("%s, search_i:\n\t %lld\n", __func__, t); }
struct node *build(char in[],char pre[],int ins,int ine) { if(ins>ine) return NULL; struct node* temp; temp=get_node(pre[ins]); if (ins==ine) return temp; int i=search_i(in,ins,ine,temp->data); temp->left=build(in,pre+1,ins,i-1); temp->right=build(in,pre+i+1,i+1,ine); return temp; }