Question: Data Cleanup In this section, you will be working with the Shuffle-Left Algorithm and the Converging Pointers Algorithms. Start the lab software as usual. Click
Data Cleanup In this section, you will be working with the Shuffle-Left Algorithm and the Converging Pointers Algorithms. Start the lab software as usual. Click on the Cleanup Animator button on your lab software menu. Select Shuffle-Left Cleanup from the Algorithm menu. For this algorithm, the number of times a data item is copied to another position depends on the number of 0s (bad data items) and also on the positions in which the 0s are located in the list. Click on the Reset button until you get a data set with three or four 0s. Record the position of the 0s on the original list. Now Step through the algorithm and observe and record where each 0 is located when it is first detected by the if statement in Step 5 (it might have moved from its original location!). Also observe and record how many copy operations (Step 10) are executed after each 0 is detected. Repeat this process until you are ready to answer the following questions. Answer all numbered questions on a sheet of paper, which you will hand in when you are done.
1. With a list of 8 elements, if a 0 is detected at position k, how many copy operations are needed to shuffle the remaining elements left one position? 2. What if there were n items in the list instead of 8? 3. If the first 0 is originally in position k, where will it be when it is detected by the if statement? 4. If the second 0 is originally in position k, where will it be when it is detected by the if statement? 5. If the j-th 0 is originally in position k, where will it be when it is detected? 6. Suppose we have a list with 200 items, and suppose that this list has three 0s located in positions 47, 110 and 162. How many copies would be performed by the Shuffle-Left algorithm in order to clean up this data set?
7.How many copies would be performed by the Converging-Pointers algorithm in order to clean up this data set?
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
