std::vector<int> a;
int p;
int N;
// ...
p = a[ N>>1 ];
What is the N>>1
part?
std::vector<int> a;
int p;
int N;
// ...
p = a[ N>>1 ];
What is the N>>1
part?
Divides N by 2 (by bit shifting right 1) and using that as the index into the vector a to assign p.
It looks like it sets p
to the middle element of a
. if a
is sorted, it would be the median element, and could be part of a binary search algorithm.