Click here to Skip to main content
15,888,113 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: IPC Thru WM_COPYDATA Pin
Rick York9-Feb-17 6:58
mveRick York9-Feb-17 6:58 
GeneralRe: IPC Thru WM_COPYDATA Pin
ForNow9-Feb-17 8:22
ForNow9-Feb-17 8:22 
AnswerRe: IPC Thru WM_COPYDATA Pin
leon de boer2-Feb-17 23:45
leon de boer2-Feb-17 23:45 
QuestionThr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba2-Feb-17 15:37
alalba2-Feb-17 15:37 
AnswerRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
Midi_Mick2-Feb-17 16:12
professionalMidi_Mick2-Feb-17 16:12 
GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba2-Feb-17 16:22
alalba2-Feb-17 16:22 
GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba3-Feb-17 4:05
alalba3-Feb-17 4:05 
AnswerRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
leon de boer2-Feb-17 23:18
leon de boer2-Feb-17 23:18 
Ok I want you to get out pen an paper and do this on a piece of paper

You have have two integers in an array and the pointer to the first one we will call zero. So the second pointer must be exactly one integer away so it will be sizeof(integer) from the first pointer.

Can you get what the result of this is (tail-start)/2 .. I will give you a hint if an integer is 2 bytes the answer is 1 byte. It doesn't matter what divisions you do after that you have lost alignment to the array your result can be some point in the middle of an integer.

Nothing in all the code above deals with that problem and it's really simple to fix all you need is to add a simple +1 in exactly the right place. Start by fixing the alignment problem and most of the rest will drop out which was sort of the second you cottoned onto what is the middle of the array and what does that actually mean. Take a one integer array what is the middle mean, your code has to know what to do with pathological case. The two integer array is an edge case on dealing with even number arrays where the middle of the array isn't aligned to an integer pointer.

This whole concept is sometimes called the post and fence problem, where you always need one more post than the gaps you span if you need to search.

modified 3-Feb-17 5:26am.

GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba3-Feb-17 4:25
alalba3-Feb-17 4:25 
GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
leon de boer3-Feb-17 7:12
leon de boer3-Feb-17 7:12 
GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba3-Feb-17 12:46
alalba3-Feb-17 12:46 
SuggestionRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
David Crow3-Feb-17 3:47
David Crow3-Feb-17 3:47 
GeneralRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
alalba3-Feb-17 4:26
alalba3-Feb-17 4:26 
AnswerRe: Thr problem of the recursive algorithm to do binary search in a sorted array Pin
Patrice T8-Feb-17 6:20
mvePatrice T8-Feb-17 6:20 
QuestionStupid build issue - has to be an include file issue.... Pin
charlieg2-Feb-17 15:23
charlieg2-Feb-17 15:23 
AnswerRe: Stupid build issue - has to be an include file issue.... Pin
Peter_in_27802-Feb-17 16:18
professionalPeter_in_27802-Feb-17 16:18 
AnswerRe: Stupid build issue - has to be an include file issue.... Pin
leon de boer2-Feb-17 23:01
leon de boer2-Feb-17 23:01 
GeneralRe: Stupid build issue - has to be an include file issue.... Pin
charlieg3-Feb-17 1:05
charlieg3-Feb-17 1:05 
QuestionLNK2019 unresolved external symbol with Ultimate Toolbox COXTootlTipCtrl and ::MonitorFromRect Pin
Gagnon Claude30-Jan-17 5:02
Gagnon Claude30-Jan-17 5:02 
AnswerRe: LNK2019 unresolved external symbol with Ultimate Toolbox COXTootlTipCtrl and ::MonitorFromRect Pin
Richard MacCutchan30-Jan-17 6:35
mveRichard MacCutchan30-Jan-17 6:35 
GeneralRe: LNK2019 unresolved external symbol with Ultimate Toolbox COXTootlTipCtrl and ::MonitorFromRect Pin
Stefan_Lang30-Jan-17 21:39
Stefan_Lang30-Jan-17 21:39 
GeneralRe: LNK2019 unresolved external symbol with Ultimate Toolbox COXTootlTipCtrl and ::MonitorFromRect Pin
Richard MacCutchan30-Jan-17 22:18
mveRichard MacCutchan30-Jan-17 22:18 
AnswerRe: LNK2019 unresolved external symbol with Ultimate Toolbox COXTootlTipCtrl and ::MonitorFromRect Pin
Member 1489195816-Sep-20 6:40
Member 1489195816-Sep-20 6:40 
QuestionProblem Creating C++ Console App Pin
Kevin Marois27-Jan-17 8:18
professionalKevin Marois27-Jan-17 8:18 
AnswerRe: Problem Creating C++ Console App Pin
Rick York27-Jan-17 8:28
mveRick York27-Jan-17 8:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.