i will quote the exact question i have been given:

You have 2 linked lists, l1 and l2, which merge into 1 list on a certain node, find that node.

but it must be with O(n+m), when n and m are the length of the 2 lists, Untill the shared node.

You may use additional O(1) extra memory.

now i know how to find the common link, when n and m are the total length of the lists, but given the fact that i can only reach to the first common node, i cant find a possible solution, ofc you cant put flags or change the lists.

any ideas? ]]>

Given a number, find the next higher number which has the exact same set of digits as the original number. For example: given 12478 return 12748.

It doesn't seem to be working. I'm missing something somewhere....

Code:

`public int findNextBig(int input ) {`

//Step 1: split the whole number to a list for individual digital 1358642->[2,4,6,8,5,3,1]

// this step is O(n)

int digitalLevel=input;

List<Integer> orgNumbersList=new ArrayList<Integer>() ;

do {

Integer nInt = new Integer(digitalLevel % 10);

orgNumbersList.add(nInt);

digitalLevel=(int) (digitalLevel/10 ) ;

} while( digitalLevel >0) ;

int len= orgNumbersList.size();

int [] orgNumbers=new int[len] ;

for(int i=0;i<len;i++){

orgNumbers[i ] = orgNumbersList.get(i).intValue();

}

//step 2 find the first digital less than the digital right to it

// this step is O(n)

int firstLessPointer=1;

while(firstLessPointer<len&&(orgNumbers[firstLessPointer]>orgNumbers[ firstLessPointer-1 ])){

firstLessPointer++;

}

if(firstLessPointer==len-1&&orgNumbers[len-1]>=orgNumbers[len-2]){

//all number is in sorted order like 4321, no answer for it, return original

return input;

}

//when step 2 step finished, firstLessPointer pointing to number 5

//step 3 fristLessPointer found, need to find to first number less than it from low digital in the number

//This step is O(n)

int justBiggerPointer= 0 ;

while(justBiggerPointer<firstLessPointer&& orgNumbers[justBiggerPointer]<orgNumbers[firstLessPointer]){

justBiggerPointer++;

}

//when step 3 finished, justBiggerPointer pointing to 6

//step 4 swap the elements of justBiggerPointer and firstLessPointer .

// This is O(1) operation for swap

int tmp= orgNumbers[firstLessPointer] ;

orgNumbers[firstLessPointer]= orgNumbers[justBiggerPointer] ;

orgNumbers[justBiggerPointer]=tmp ;

// when step 4 finished, the list looks like [2,4,5,8,6,3,1] the digital in the list before

// firstLessPointer is already sorted in our previous operation

// we can return result from this list but in a differrent way

int result=0;

int i=0;

int lowPointer=firstLessPointer;

//the following pick number from list from the position just before firstLessPointer, here is 8 -> 5 -> 4 -> 2

//This Operation is O(n)

while(lowPointer>0) {

result+= orgNumbers[--lowPointer]* Math.pow(10,i);

i++;

}

//the following pick number from list from position firstLessPointer

//This Operation is O(n)

while(firstLessPointer<len) {

result+ orgNumbers[firstLessPointer++ ]* Math.pow(10,i);

i++;

}

return result;

}

Hello, I think my previous postings were a bit confusing. I just wanted to clarify that in this posting. I have a plane and attached figure shows two positions of the plane, (a) no rotation and (b) with rotation where rotation axis is defined by ax + by + cz.

Now, the plane will rotate, but it will always look without rotation as shown in figure (a).

I think I need to play around with my glutReshape function which looks like follows:

Quote:

void glutReshape(int width, int height)

{

width = glutGet(GLUT_WINDOW_WIDTH);

height = glutGet(GLUT_WINDOW_HEIGHT);

if (width && height)

{

glViewport(0, 0, width, height);

nearDist = 150.0 / tan((kFovY / 2.0) * kPI / 180.0);

farDist = nearDist + 100.0;

aspect = (double) width / height;

glMatrixMode(GL_PROJECTION);

glLoadIdentity();

gluPerspective(kFovY, aspect, 0.1, farDist+20);

glMatrixMode(GL_MODELVIEW);

glLoadIdentity();

gluLookAt( 0.0, 0.0, (nearDist + 5.0), // camera/ eye

0.0, 0.0, 0.0, // center

0.0, 1.0, 0.0); // up vector

}

}

But what about the up vector? How will it change for this rotation? How can I calculate new up vector? Also what other parameters in my glutReshape function needs to be changed?

Please provide me some suggestion how can I fix this problem.

Thanks in advance.

Thanks. ]]>

Hello, this is some continuation of my previous posted topic on transformation. I have attached two pictures of rotation of different axes, i.e. X, Y and Z. Z rotation is the projection on XY plane for two different Z rotation. It shows how the length of the axis varies depending on Z rotation. Now my question is, from this information is it possible to figure out rotation of Z axis. Here as rotation is on XY plane, the length of X and Y axis does not vary, but that of Z-axis varies.

Thanks in advance.