Change Contents of the Bubble
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

FinalExam Review Fall2005: And a One and a Two

Questions? Comments? Answers?
(Back to Final Exam Review Fall2005)


I have no idea what this one is actually asking us to do. can somebody decipher this for me? Removed at KS request

If you had a list "F->G", and you said nodeF.weaveOneAndTwo("A","B",3), you would expect to get "F->A->B->B->A->B->B->A->B->B->G" A->B->B (a one A and a two B), three times, got inserted after F. Mark Guzdial


that makes much more sense! thank you!Removed at KS request

public void weaveTwo(SongNode nextOne, SongNode nextTwo, int skipAmount)
{
SongNode current = this; // Start from here
SongNode copy; // Where we keep the one to be weaved in
SongNode copy2;
SongNode copy3;

for (int i=1; i = skipAmount; i++)
{
copy = nextOne.copyNode(); // Make a copy
copy2 = nextTwo.copyNode();
copy3 = nextTwo.copyNode();

current.insertAfter(copy);
current = current.next();
current.insertAfter(copy2);
current = current.next();
current.insertAfter(copy3);
current = current.next();
skipAmount++;

}
}

This makes sense to me at least. insertAfter() keeps track of oldNexts right? so we don't need that jazz about saving the oldNext in this particular one do we? This is also a pretty in depth problem for an exam, i don't know about this one....
Kyle DuPont

You're right, Kyle. You don't have to save the oldNext "jazz." And this is harder than I can be expected to put on the final exam. Mark Guzdial



Link to this Page