Determining index to place new value

Hello. I need help with function to determine where to place new element in sorted array. I want to use binary search to find index where element should be placed, when push all others.
Prototype should be something like
int WhereToPlaceElement(ElementType hash); // uses private atribute ElType** elements
I have tried my best to write, but all tries ended in inf loops and reading invalid locations of array. Please help.
So you are having trouble doing a binary search on hash->elements[]?

Must you write the binary search function yourself, or can you use the STL?
http://www.cplusplus.com/reference/algorithm/upper_bound/
I need to write it by myself.
Well, post the best code you have (the stuff you think or see working best) and we'll try to help detangle your fencepost errors.
Topic archived. No new replies allowed.