Topic awaiting preservation: Java Blues (Page 1 of 1) |
|
---|---|
Nervous Wreck (II) Inmate From: Weddington, NC, US |
posted 03-04-2004 15:53
how would I go about writing a recursive method |
Paranoid (IV) Mad Scientist From: Somewhere over the rainbow |
posted 03-04-2004 15:58
The poster has demanded we remove all his contributions, less he takes legal action. |
Paranoid (IV) Mad Scientist with Finglongers From: Germany |
posted 03-04-2004 17:15
On a side note: Recursing is just iteration plus a stack. Therefore, iteration can be simulated via recursion (and essentially is in all 'tail-recursive' languages, which may ommit the stack if it's not needed), and recursion can be simulated via an iteration and a stack. |
Paranoid (IV) Inmate From: Milwaukee |
posted 03-04-2004 19:34
Why recursion? You could just do this: code: [b]public static int[/b] search([b]int[/b][] numbers, [b]int[/b] target)
|
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 03-04-2004 23:23
I am going to say that he has to recurse the array because that is what the assignment entailed... code: public static int search(int a[], int m, int n, int target){
|
Nervous Wreck (II) Inmate From: Weddington, NC, US |
posted 03-05-2004 14:48
that helps, thanks guys. Luckily this is graded for effort, so if it looks like it could work then I think i'll still get a good grade. The teacher doesn't really know one way or the other so it's all good. I made an array of 5, 3, 2, 1, and 4 but i didnt know what to use the other ints for so I just improvised |
Maniac (V) Mad Scientist From: Rochester, New York, USA |
posted 03-05-2004 15:58
I can actually picture uses of such a search method. |