Luke Forga

Greenhorn
+ Follow
since Jul 17, 2005
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Luke Forga

Understandable. Sorry about any confusion; however, I corrected the problem(s) and it is now working. Thanks again.
18 years ago
would someone be so kind as to take a look at it and tell me what I have done to it. The code, shown below, are two classes.

------------------------------------------------------------------

--------------------------------------------------------------------
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
--------------------------------------------------------------------

----------------------------------------------------------------------
18 years ago
Nix the question, as I have figured it out. Thanks for the "post" space.
18 years ago
Would someone enlighten me as to how the following minheap, h, would look after the following operations were performed.

a) h.heapInsert(8)
b) h.heapInsert(5)
c) h.heapDelete()
4
/ \
/ \
7 9
/ \ / \
10 12 13 11

A brief explanation of a solution to any "one" should be sufficient for me to figure out the other(s). Thanks in advance.
18 years ago
Could someone help me put together a method which uses a stack to reverse the order of elements in a queue. This can be a generic method...as I will tweak it for implementation. Thanks in advance.
18 years ago
Good deal. I didn't see that "side2+=side2. Silly me. Much appreciated. Thanks again for your assistance.
18 years ago
I seem to be having difficulty in producing an output. It compiles...just doesn't output anything. Where have I gone wrong, may I ask? Thanks in advance!


public class PythagoreanTriples
{

public static void main( String args[] )
{
int side1;
int side2;
int hypotenuse;
int limit = 5;
int i=0;

/* Loop for side1 to try the values 1-limit. */
for (side1=1; side1<limit; ++side1)
{

/* Loop for side2 to try the values 1-limit. */
for (side2=side1+1; side2<limit; ++side2)
{ side2+= side2;

/* Loop for hypotenuse to try the values 1-limit */
for(hypotenuse=side2+1; hypotenuse<limit; ++hypotenuse)
{

/* An if statement that determines whether the sum of the two sides squared equals the hypotenuse squared. If this condition is true display side1, side2 and hypotenuse. */
if(side1*side1+side2*side2 == hypotenuse*hypotenuse)
{
System.out.printf(" %d : ( %d, %d, %d )\n", ++i, side1, side2, hypotenuse);
} // end if
} //end innermost for
} //end inner for
} //end outer for
} //end main

} // end class
18 years ago
No doubt this problem is simple for most; however, I seem to be having difficulty in producing any output. It compiles...just doesn't output anything. Where have I gone wrong, may I ask? Thanks in advance!


public class PythagoreanTriples
{

public static void main( String args[] )
{
int side1;
int side2;
int hypotenuse;
int limit = 5;
int i=0;

/* Loop for side1 to try the values 1-limit. */
for (side1=1; side1<limit; ++side1)
{

/* Loop for side2 to try the values 1-limit. */
for (side2=side1+1; side2<limit; ++side2)
{side2+= side2;

/* Loop for hypotenuse to try the values 1-limit */
for(hypotenuse=side2+1; hypotenuse<limit; ++hypotenuse)
{

/* An if statement that determines whether the sum of the two sides squared equals the hypotenuse squared. If this condition is true display side1, side2 and hypotenuse. */
if(side1*side1+side2*side2 == hypotenuse*hypotenuse)
{
System.out.printf(" %d : ( %d, %d, %d )\n", ++i, side1, side2, hypotenuse);
} // end if
} //end innermost for
} //end inner for
} //end outer for
} //end main

} // end class Triples
18 years ago
Thanks Steve. I appreciate your help on the matter.
18 years ago
I am needing someone to give me a hint...steer me in the right direction as to how I should approach this problem. The key, I'm thinking, is obtaining some value for n. With such a value I should be able to solve the problem. Any thoughts? Suggestions. Thanks in advance.

Consider the following Java method f. Do not be concerned with f's purpose. How many comparisons does f perform?
===========================================================================
public static void f(int[] theArray, int n)
{
int temp;
for (int j = 0; j < n; ++j)
{
int i = 0;
while(i<=j)
{
if(theArray[i] < (theArray[j]))
{
temp = theArray[i];
theArray[i] = theArray[j];
theArray[j] = temp;
} //end if
++i;
} //end while
} //end for
} //end f
18 years ago
I have a couple problems here that I have answered. I am not 100% sure of my answer(s). Would you be so kind as to check them and provide suggestions/solution if they are not correct. These 2 questions are regarding what methods super/sub class(es) can invoke (question1) and which objects invoke which methods (question2). Thanks in advance.

Question 1
=========================================================================
Super Class: Expression (Includes prefix, postfix, and infix expressions)
Public Method: characterAt
Protected Method: isOperator
Protected Method: isIdentifier
Private Method: somePrivateMethoda
Private Method: somePrivateMethodb

SubClass: InfixExpression (Derived from Expression. Represents infix expression)
Public Method: isLegal
Public Method: evaluate
Protected Method: someProtectedMethoda
Protected Method: someProtectedMethodb
Private Method: anotherPrivateMethoda
Private method: anotherPrivateMethodb
======================================================================
What methods can the implementation of isIdentifier invoke?
CharacterAt
isOperator
somePrivateMethoda
somePrivateMethodb

What methods can the implementation of isLegal invoke?
characterAt
isOperator
isIdentifier
evaluate
someProtectedMethoda
someProtectedMethodb
anotherPrivateMethoda
anotherPrivateMethodb


Question 2
Assuming the classes described in the previous question and consider a main method that contains:

Expression algExp;
InfixExpression infixExp;

Soooo...
==================================================
Super Class: Expression (Includes prefix, postfix, and infix expressions)
Main Method: algExp
Public Method: characterAt
Protected Method: isOperator
Protected Method: isIdentifier
Private Method: somePrivateMethoda
Private Method: somePrivateMethodb

SubClass: InfixExpression (Derived from Expression. Represents infix expression)
Main Method: infixExp
Public Method: isLegal
Public Method: evaluate
Protected Method: someProtectedMethoda
Protected Method: someProtectedMethodb
Private Method: anotherPrivateMethoda
Private method: anotherPrivateMethodb
==================================================
Which of these objects can correctly invoke the method CharacterAt?
algExp and infixExp

Which of these objects can correctly invoke the method isOperator?
algExp and infixExp

Which of these objects can correctly invoke the method isLegal?
infixExp
18 years ago