1. There is an ordered sequence of {1,3,9,12,32,41,45,62,75,77,82,95,100}, when finding a node with a value of 82 with a dichotomy, does the lookup succeed after several comparisons?
The question needs to be answered by using dichotomy to find ideas, using *low to point to the first element of the sequence, low=1;*high pointing to the last element of the sequence, high=13; Mid is the middle element, mid= (Low+high)/2,
Use the Reference code:
int binsearch (int r[],int n,int k) {
Low=1;high=n;
while (Low<=high) {
Mid= (Low+high)/2;
if (K<r[mid]) high=mid-1;
else if (K>[mid]) low=mid+1;
else return mid;
}
return 0;
}
Cycle 4 times
2. Press the new element into the sequential stack, move the top pointer first, and then deposit the element .
3. Logically divides the data structure into the linear structure, the nonlinear structure two categories.
4. A left and right subtree of two forks the number of empty pointer fields is 1after the preceding sequence is threaded.
Data structure Analysis method