Question: Please do it for complexity O(M(k)) Consider a set of n boxes with their positions numbered from 1 to n. Initially all the boxes are

Please do it for complexity O(M(k)) Consider a set of n boxesPlease do it for complexity O(M(k))

Consider a set of n boxes with their positions numbered from 1 to n. Initially all the boxes are CLOSED. These n boxes are subject to modifications over n iterations as follows. At the ith iterations the boxes at the positions whose ids are multiples of i are flipped, i.e. changed from CLOSED to OPEN or vice-versa. For example, at iteration 1, boxes at all positions are flipped, at iteration 2, boxes at positions 2,4,6,etc. are flipped, at iteration 3, boxes at positions 3,6,9, etc. are flipped. Propose an algorithm for find out, that after n such iterations how many boxes will be OPEN. Note that the answer requires only how many boxes, not their positions. Describe the rationale for the algorithm, give the pseudocode, and its complexity. Grading scheme: (your grade will be based on whichever class your algorithm falls in) For algorithms with complexity O(n) or higher (10 pts) . For algorithms with complexity (kn), where k is the number of digits of n (15 pts) For algorithms with complexity O(M(k)), where k is the number of digits of n, and M(k) is the complexity of multiplying two k digit numbers (20 pts)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!