Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Please follow the notation in the class solution part. The time complexity should not be O(n^2), and it should be better than O(n^2). Test cases

Please follow the notation in the class solution part. The time complexity should not be O(n^2), and it should be better than O(n^2). Test cases have large numbers to test.

image text in transcribed

Amicable pairs Consider the number 220. Find the sum of factors, except the number itself (also called proper divisors). 220=1+2+4+5+10+11+20+44+55+110=284 Now find the sum of factors for 284 : 284=1+2+4+71+142 220 and 284 are called amicable pairs. Write a program that 1. prints all the amicable pairs 2 . the number of steps took to compute amicable pairs. The time complexity should not be O(n2), it should be lower/better than O(n2). \#\# a[0] = How many amicable pairs are there in n.__increment_number_of_pairs \#\# a[1] = num_steps__increment_steps class Solution: def__init_(self,n:'int',a:'list of size 2'): self._n n=n \#\#a[0] = How many amicable pairs are there in n._increment_number_of_pairs \#\#a[1] = num_steps__increment_steps self._list = a \#\#You can have any number of data structures here \#\# Nothing can be changed below self._alg() def_increment_steps(self)->'none': self._list[1] = self._list[1] + 1 def_increment_number_of_pairs(self)->"int": self._list [0]= self._list[0] + 1 return (self._list[0]) \#\#You can have any number of private variables and functions def_alg(self): \#\#Implement your code below If n=10000, the answer should look similar to this

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions