NintendoMan07
Smash Journeyman
I'm urgently needing to turn in a project for a class that's already late as is, but I'm stuck.
// Clear the tree. Create an array P of 500 integers with values 1, 2, 3, ..., 500
// Shuffle the array randomly. Then,
// for(int i=0;i<5000; i++) {
// Pick a randomly positioned integer from the array P
// and insert that value into the tree.
// Pick a randomly positioned integer from the array P
// and delete that value from the tree, if it is present.
// Don't print anything during the operation.
// }
How would I write the code for the stuff in bold?
If I can figure out how to do the random shuffling and picking at random, the rest of it I have some idea how to do.
As for the full context of the project, this part utilizes a binary search tree (not from the Java Collections Framework), and there's different commands involved. This is one of them.
And yeah, I've been in college learning Java for two years, so weep for the future of humanity if this ends up being a really stupid thing to be stuck on.
// Clear the tree. Create an array P of 500 integers with values 1, 2, 3, ..., 500
// Shuffle the array randomly. Then,
// for(int i=0;i<5000; i++) {
// Pick a randomly positioned integer from the array P
// and insert that value into the tree.
// Pick a randomly positioned integer from the array P
// and delete that value from the tree, if it is present.
// Don't print anything during the operation.
// }
How would I write the code for the stuff in bold?
If I can figure out how to do the random shuffling and picking at random, the rest of it I have some idea how to do.
As for the full context of the project, this part utilizes a binary search tree (not from the Java Collections Framework), and there's different commands involved. This is one of them.
And yeah, I've been in college learning Java for two years, so weep for the future of humanity if this ends up being a really stupid thing to be stuck on.