Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!

# Broken code

Andres John
Ranch Hand
Posts: 34
The code is working fine but there is some problem in the algorithms of this problem like i wants a match to be equal to 15 but instead is give me 16 somehow, here is the code:

output:
1 2 3 3 4 7 7 9 10 10
16 17 18 18 19 19 20 20 21 21
21 25 27 27 29 30 31 36 38 39

40 the position of the match is 16

Tony Docherty
Bartender
Posts: 2942
59
40 the position of the match is 16

Sorry but that makes no sense to me. What is this algorithm supposed to do and what does it actually do?

Andres John
Ranch Hand
Posts: 34
Tony Docherty wrote:
40 the position of the match is 16

Sorry but that makes no sense to me. What is this algorithm supposed to do and what does it actually do?

this program support to do a recursive method or recursion, it actually sort it the number from lower to high using fastsorting (if you already read the comments)

colton peterson
Ranch Hand
Posts: 97
I am still thoroughly confused, for the following reasons:

The printlns in your code do not match the output you gave

Even though you mentioned that the algorithms are supposed to sort something, it looks to me like they are for searching through arrays using different methods, not sorting them

Also you have no main method, and your methods do not call each other, so I do not even know which method you are asking about, as they do different things

40 the position of the match is 16

this line in particular, what does it mean? When searching for 40 it returns that the position is 16? Vice versa? something else entirely?

In the method interpolationSrch() (which I think is the one you are asking about), what do v, s, and e mean? value, start, end? those one letter parameters are killing me. If so I still need to know what you originally call it with to be much more helpful.

I am not trying to sound harsh, I am just very confused, if you could clarify any of the above points, I am sure we could be a lot more helpful in answering your questions