Answer:
The final case in selection sort is trivially sorted.
The final iteration in insertion sort is not needed.
Explanation:
For selection sort, you make sub arrays and find the smallest element placing it in the front and repeat until sorted. This guarantees the final element will already be the greatest element, thus it is trivially sorted.
For Insertion sort, you use the initial element and compare it to the previous element and swap if the current is larger than the previous. Using this sort, you will always perform n-1 comparisons where n is the total amount of elements in the array. Thus, there are only 11 iterations for a 12 element array.
Cheers.
Answer:
Revisiting "Build a Tower"
Recall in the last section how we made Karel make a tower of tennis balls. We told Karel to move() and turnLeft() and putBall() until we had a tower. At the end of the program, Karel was still at the top of the tower, like as in the picture below.
Stuck at top
Suppose that now we want Karel to come back down from the top of the tower. The first thing we need to do is get Karel facing in the right direction. One way to do this is to tell Karel
turnLeft();
turnLeft();
turnLeft();
And then tell Karel to
move();
move();
move();
back to the bottom of the tower.
However, telling Karel to turnLeft() three times is not very readable. That's a lot of writing when all we really want is to tell Karel to "turn right."
Explanation:
Hopefully it would help.
Answer:
Travelling in time might sound like a flight of fancy, but some physicists think it might really be possible. BBC Horizon looked at some of the most promising ideas for turning this staple of science fiction into reality.
Explanation:
The prewriting process should include brainstorming a topic, deciding on which topic on which to write, research of a topic, organizing the research into a comprehensive whole. Check out an APA style textbook, should be available at the library, and it should have more results in the prewriting process. Of course, the writing process itself depends on the individual and his or her cognitive process on writing.