I'm not going to read all that unformatted code (use the CODE button or [code] and [/code] tags). One thing I happened to notice though: It seems you're not storing enough information. grid[row][column] has three states, open, tried, and blocked. I'm not sure what that's supposed to represent, but I'd expect that you'd need to store state not jsut for each ... 
2. Recursion forums.oracle.com 
I have the same homework problem, which is due monday.. but i don't know why, i can't get my recursions to work.. first my sorting, public static void quickSort(int[] dA, int first, int last) { int pivotIndex =1 ; if(first 
Presumably that code is in a method called "recurse". Think about what happens with the recursive calls. First, the method is invoked. It executes the statements before the recursive call, then it invokes the recursive call, then it executes the statements after the recursive call. And what happens during the recursive call? As before, it executes the statements before the recursive ... 

I'm fairly new to Java. I would like to build a JTree to represent a File structure. I choose the a top file to make the root and then display the entire structure of the file. There might be an easy way to do this already, I would think there would be, but I haven't found an example of it. The ... 
Ok, yes this is homework.... I have gotten very far... Now.. I am wondering how I can edit my code so it will print what I want. If you run the program it wont do what its suppose to do... if i put in 1234 it will print 4 3 2 1 on different lines... I guess I am wondering how ... 

Thank you again. After running that I think I better understand but still not completely. So does it store all the input integers until its finished recursing then print them after its finished? If this is what it does, where does it store the integers and how does it not overwrite input every time the method is called? Also why does ... 
9. recursion forums.oracle.com 
10. recursion forums.oracle.com 


not a grade just an inclass assignment that we are starting next week, however, i skipped the precursor to the A.P. computer science class that I am in, so in many topics I am behind, most of the class has a general idea of how to create such methods however, I do not have any background with recursion and am not ... 
So i have a little problem. Im writing a method that will go though a binary search tree and print out all the nodes in the tree in the pattern of an inorder traversal. What it is supposed to do is print out 3 things, the element in the node, its number in the inorder sequence, and the depth of that ... 
mark, I suspect that you're actually struggling to understand the passing of arguements to methods... I suggest you leave recursion for now... it (recursion) is IMHO the most overrated "patterns" ever invented, despite the fact the every textbook covers it, mainly (again IMHO) for it's "gee wiz" factor. There's almost always a simpler iterative solution. Calculating a factorial is notable exception ... 


well i think that the first method makes it so that the sum of the array is greater then or equal to to what it was before. as for the recursion i wont be able to do it until i dont know for sure what secondMethod does... Ok, then first figure out what that does then. You can do this by ... 
Please help, I've been stuck on this for many days. I'm supposed to make a java program that displays the following fractal: http://www.seattlecentral.org/faculty/flepeint/java143/hw3/pluses.gif The first level is displayed upon startup. The level increases everytime the recursive method is called. The variables I have are: type Plus north, south, east, west, parent; The recursive method should create new Plus(int x, int y, ... 
I am having trouble with this project for my Comp Sci class. We're supposed to make an intelligent opponent using mutual recursion for the game Nim. In this variation there are 3 stacks of sticks. During a turn a player must pick up at least one stick from one pile. If it is so desired a player may take the whole ... 
21. recursion forums.oracle.com 
We just started learning about recursion and I'm still not exactly sure how it all works....and of course we now have a project to work on and I'm having trouble. The program that we're working on is supposed to compare what is typed in to see if it's a palindrome (something that when it's read forwards and backwards says the same ... 





Again! I did not write the code. I am merely supposed to find out what the program does!!! How does it get 38 as the Total Value?? The Professor of the class i am taking wrote it and would like each person to explain the code. I am having difficulty explaining the "answer" method because i am not so good at ... 
for(int b5 = n5; b5 <= n; b5++) { int a = n5; putAinB(array, a, b5); putAinB(array5, a, b5); if(b5==n5) System.arraycopy(array,0,array5,0,6); else if(b5 > n5) { System.arraycopy(array5,0,array,0,6); } for(int b4 = n4; b4 <=n ; b4++) { a = n4; putAinB(array, a, b4); putAinB(array4, a, b4); if(b4==n4) System.arraycopy(array,0,array4,0,6); else if(b4 > n4) { System.arraycopy(array4,0,array,0,6); } //putAinB(array, a, b4); for(int b3 = ... 
Recursive is nothing but a function call by itself Note: make sure that your code have proper control and terminate statements to break the loop. Other wise it wont stop leading to serious problem Just think about a recursive program dealing with the system usage This will leads to creation and production of computer virus with regards vasu_gb@yahoo.co.in 
Hi, Is there any one to make a program for me in Turbo C++ for Dos, which can calculate the square root of any number without using the sqrt( ) or any ready made functions. The program should calculate the s.root of the number by a formula or procedure defined by the user (programmer). Thanks. 
Hello people, i'm new to Java so bear with me please: I have been set a problem: Create a getForefathersRecursive method that should take a Person instance as a parameter, and calculate an array whose elements are that Person (at index 0) and all of his forefathers in ascending age order. The tricky part is that you don't know how many ... 
Ok everyone i am attempting to write a recursive program that finds f(x,y) when: f(x,y)=y+x, when x<=0 f(x,y)=4f(x1,y1), when x>0 and x is even f(x,y)=f(y2,x1), when x>0 and x is odd i have no idea what do i can solve it the math way on paper but have no idea how to make it into a program can someone shed some ... 

(A) At the 2nd deepest call, we have a=7, b=7. We're returing a + mys(a+2,7), which is 7 + 0, since mys(7+2, 7) gives us the a>b case. (B) The one that called (A) will return 5 + 7. (C) The one that called (B) will return 3 + 12. The one that called (C) will return 1 + 15. 
1. Your recursive function should accept thre lists  result, first and second. 2. Function should do nothing and return if both first and second lists are empty. 3. If one list is empty function should add first element of nonempty list to result and call itself with empty list and other list without first element. 4. If both lists are ... 
I still think there is a more recursive solution and shorter solution I think there is too. One sort of operation that can be applied to an integer is to find a factor and use that factor produce another one such that the product is the original integer. For instance 24 can be "broken down" into 8 and 3 (or into ... 
/** * This is a recursive method that finds the Maximum Subsequence * Sum in a passed array. * * @param a  passed array * @param start  beginning of array * @param end  end of array * @return  returns the largest of the 3 integers passed to the method * maxOfThree. */ 
39. recursion forums.oracle.comThe result (120) is of course wrong but that's not the point. Ok, so ho can I do what I want (trace the recursion basically) ?is it possibile to do that without use the 'return'? I must do simething that computes the Fib numbers and trace the recursion. Hope clear what I need. 
40. recursion forums.oracle.comT50409143 wrote: I understand basic recursion. But how would I figure out a poker hand? recursion for a deck of 52 cards. 5 cards in each hand. How could I figure that out? This is not clear as you don't tell us what you mean by "figure out a poker hand", nor what role recursion has in this. Do you want ... 
41. recursion forums.oracle.com 
You don't print the comma when you're at the top of the stack. So for example, you could have the caller print the comma, and not print the comma after you first invoke the function. Or you could just pass a flag to the recursive method. Set it to true to print suppress the comma. The function ANDs the argument with ... 



I'm currently working on a small programming project that incorporates a recursive function implementation and I was hoping to get some suggestions/help. The program involves finding the minimum value in a generic ArrayList. The declaration is as follows: ArrayList theArray = new ArrayList(); int size = 0; I know that size can be found with size() method but we are limited ... 

I have been doing a few mathematical java recursion problems lately to get in the swing of things with the logic, and have come across a program I simply cannot seem to solve. There are four balls in a bag, black, red, blue and yellow. At random, a ball is pulled from the bag, and then placed back into the bag. ... 
There are too many mistakes here to mention all. Some include: 1) Trying to assign 0 to an array before first initializing the array. You know how big it should be, so I'd construct the array first before assigning. 2) Creating a Scanner object and doing nothing with it. 3) Using an undeclared variable, "x". 4) Declaring the board array local ... 




54. Recursion forums.oracle.com 
I have a method that recursively executes a maximum of 30 000 times until it completely terminates, when I run the method it returns an exception. However, if I limit it to executing 10 000 times I don't get the exception. I think the exception is an overFlowException, if I recall correctly. My question is: does the concept of recursion allow ... 
mate, i have no knowledge on atoms being attached to ring structures , cant actually believe that they are attached in the first place. If you gave me the expected output for the input you provided , maybe i can figure out why you think they are attached ..... Maybe you should just go with what ejp said , he sure ... 
Sample 1 ================================== Resource: [Resource 1 : available] Resource: [Resource 1.1 : UNAVAILABLE] Resource: [Resource 1.2 : available] Resource: [Resource 1.3 : available] Resource: [Resource 1.3.1 : available] Resource: [Resource 1.3.2 : UNAVAILABLE] Resource: [Resource 1.3.3 : available] Resource: [Resource 1.3.4 : available] Resource: [Resource 1.3.4.1 : available] Resource: [Resource 1.3.5 : available] Resource: [Resource 1.4 : UNAVAILABLE] 
Ok, for this program I'm trying to recursively repeat an image 3 times with varying widths and heights, and I don't know how to do that with images. With rectangles and other shape objects it's easy because all I had to do was override the draw method, but with images I'm not sure what to override to allow me to repeat ... 

gdawgrancid wrote: I posted this in another topic for a previous problem of mine, but since it was a new question I guess it would be better if it had a new thread. I have to create a program that finds all the possible ways of filling a board of size 3xN (N is whatever the teacher wants). You place a ... 

62. Recursion forums.oracle.com 
BufferedReader in = new BufferedReader (new InputStreamReader(System.in)); System.out.println("Enter the source directory/file name : "); String source = in.readLine(); File src = new File (source); if (src.isDirectory()) { String zipFile = source + ".zip"; zipFolder (source, zipFile); } else { int lastDot = source.lastIndexOf("."); String zipFile; if (lastDot != 1) { zipFile = source.substring(0, lastDot) + ".zip"; } else { zipFile = ... 

65. Recursive forums.oracle.com 
I am trying to create a program that diplays a resursive picture. I got the picture to display in a JFrame and the recursion works but it creates a new smaller JFrame each time. Is there some way to make the picture reprint in the same JFrame without creating a new one everytime? Edited by: kenporic on Sep 28, 2008 5:03 ... 

To loop the way you want, you need to use a loop construct  makes sense. This often means using a forloop if you know in advance how many times you want to loop (you don't), or using a while loop if you don't (your case). I recommend you write a small program that just takes an input String, spits it ... 
69. recursion forums.oracle.comClick here(due to limited character space): http://pastebin.com/5UxzcABX I've written a game program which inputs a number from the user and creates a grid of that size. Getting five in a row of your side wins the game but the 'computer's' recursive call within the chooseMove method takes way to long to choose the best move. I am sure this code works ... 
I'm working on this project and I need some help. What I've got is an ArrayList of objects each of which consists of (name, x coordinate, y coordinate). What I need to do is generate a combination of all possible combinations of objects and print their name. The method in which I am trying to write takes a subset size. For ... 

Hello everyone, I'm a 1styear CS major and am new to Java. I had a question about importing packages. As I understand it, when you use a wildcard when importing, it will import the classes within the package specified before the asterisk, but none of the subpackages in the specified package. Sort of like in Linux when you have to pass ... 
And of course it evetually crashes. I don't understand the implication of doing this. I can't read a stack trace. All I know is a little about is reflection. Hope its some code that is fun to play with. Try starting some threads that share a static resource and see what happens. 
how do we return a value to the calling program............ _boolean flag = method(findvalue_);//main calling method method(string findvalue){ boolean tempflag = false; //get each value getting temvalue if (tempvalue.equals(findvalue)){ *return true;*//this is returning to the below calling method }else{ tempflag = method(string findvalue); } return tempflag; } Suppose there are 10 values and i am trying the second value it is ... 
Gday, I got stuck with a bit of recursion today. Basically, I'm making a method which checks if any of the children of a node in a tree contain a prefix. Then I'll store these results into an array. Then I'll go through my array and see if any of their children contain a preffix, placing those new results in an ... 

1. Write an iterative and a recursive version of the Fibonacci series algorithm. You need to ensure the correctness of the both algorithms. Both algorithms should produce similar output if given a similar input. a. Measure the performance of the two algorithms by measuring the time for both algorithms to listing out 10, 20, 30, 40, 50, 60, 70 and 80 ... 
Evaluate first, then apply the operator. Trying to get the data first doesn't make sense. If the expression were ((3 plus 5) / 2), what's the answer, and how would you do it yourself with pencil and paper? You'd calculate (3 plus 5) first, right? For your program, that's the left subtree. By the way, this also ties in with the ... 

I'm trying to get some experience with recursion, however I am having trouble starting. There is this problem in one of my Java books where I am given a certain output that i must recreate using Recursion. According to the problem, this is easily solved with 78 lines of code with 2 calls of recursions. The problem I am having is ... 

if(depth > 0 && rnd.nextInt(20depth) <= 0){ Node[] arr = new Node[2]; arr[0] = new TerminalNode(1.0); arr[1] = new TerminalNode(0.0); tree = arr[rnd.nextInt(2)]; return tree; } else { Node n = (Node) list.get(rnd.nextInt(list.size())); // if(tree instanceof BinaryNode){ // n.setLeft(generateTree(depth+1)); n.setRight(generateTree(depth+1)); tree = n; } else { n.setLeft(generateTree(depth+1)); tree = n; } return tree; } } 
Hallo, I have to write a method that get's two String type strings (s1, s2) and returns the length of the the biggest continuous sub matrix in the matrix s2 that's all it's digits are present in matrix s1. For example: if s1 is "xyz" and s2 is "abxyryxzycx" the method will return 4 because the length of sub matrix "yxzy" ... 
Hallo, I have to write a recursive method that count's the number of options when climbing 'n' stairs. There's a given variable named 'n' which is the number of stairs. You can climb or 1 stair at a time, or 2 stairs at a time or you can mix using 1 and 2 stairs in order to get to the 'n'. ... 
I got a recursion question that i can't figure out. The question:print combinations of numbers between 1 and a recieved number. example:for number 3 this should be the output [ 3 2 1 ] [ 3 2 ][ 1 ] [ 3 1 ][ 2 ] [ 3 ][ 2 1 ] [ 3 ][ 2 ][ 1 ] In every ... 
} } I am facing recursive problem . I am getting node untill firstName and LastName. When I am trying to call listnode(Element) method again for iteration purpose, Program terminates automatically. It shows null pointer exceptions.Could you please give me some suggestion on it how to solve the recursive according my input file. 

Unfortunately for my assignment, we were not even permitted the extra mnem variable in the prototype, my solution was to hide it in the prefix variable with a delimeter like "_" so that I could use my solution. Since it was an automated grading system, I still got full credit. I think this is probably the most ridiculous programming exercise I've ... 

I'm not an expert in it but I think you use recursion and a loop. So, for example: PuzzleSolve( k, S , U ) where k is an integer, S is a sequence and U a set. for each e in U do remove e from U add e to the end of S if k = 1 if S solves ... 
Since this appears to be an exercise, I'm not going to give you the actual code. However, I will say that your beginning is OK. You are messing up at the end, especially with the for loop. Let the recursion do the work for you. If n is divisible by 3, then the answer is n + recSum(n1). Or, you can ... 

originally in line 11 it said "return 1" FYI. but i have seen recursive programs that just say "return" in the base case. (i cant find the exact example im reffering to, but most of you must be knowing what im talking about) what does this mean. what does it actually "return" when the return value is not specified? Edited by: ... 
look at your code two returns in a row. The error is caused by the fact that since you have an unbracketed if statement, the second return is actually part of the method body, and th else is free floating. rule #543 of Java, even if it a one line if statement you should still bracket it because stuff like this ... 
Hi, To begin with, I'd think about giving your method a more useful name than 'n'! You're already pretty much there  you need to add a third argument to your [ahem] n method to represent the number of asterisks on each line and, within that method, loop that number of times, each time adding a single asterisk. Give it a ... 
Please do not crosspost questions in multiple forums: [CodeGuru Forums  Javahttp://www.codeguru.com/forum/showthread.php?t=460801] This will frustrate anyone who tries to help you only to find out later that the same answer was given hours ago in a crossposted thread. For this reason, many volunteers here and at the other sites refuse to help repeat offenders. 

Hey all, this is my last assignment for my CSC class and its been a struggle trying to teach myself everything up until this point and right now i really have o idea where to begin on this assignment. Assignment: Write a recursive method, power, that takes as parameters two integers x and y such that x is nonzero and returns ... 
for (ClassDef csDef : classDefs){ boolean moFound = false; if ( csDef != null){ moFound = (csDef.getMIM().getClass(notFoundMo)) != null; if (moFound) return true; else{ final ContainmentDef[] containmentRelDefForChild = csDef.getContainments(); if (!moFound  containmentRelDefForChild.length > 0) return ( isMoClassFoundInAnyDepthInThisBaseMim(notFoundMo, containmentRelDefForChild)  false ); }//end of inner if }//end of outer if }//end of inner loop }//end of outer loop 
Depends on the structure you're traversing. Has it got parent pointers? You can traverse a tree with a pretty simple set of rule like: If the current element has children, go to the first. else if the current element has siblings, go to the next sibling. else if the current element has a parent pointer follow it and repeat these rules. ... 