Question: please us python file 1.Implement the simple methods getNum and getDen that will return the numerator and denominator of a fraction. 2.In many ways it
please us python file
1.Implement the simple methods getNum and getDen that will return the numerator and denominator of a fraction.
2.In many ways it would be better if all fractions were maintained in lowest terms right from the start. Modify the constructor for the Fraction class so that GCD is used to reduce fractions immediately. Notice that this means the __add__ function no longer needs to reduce. Make the necessary modifications.
3.Implement the remaining simple arithmetic operators (__sub__, __mul__, and __truediv__).
4.Implement the remaining relational operators (__gt__, __ge__, __lt__, __le__, and __ne__)
5.Modify the constructor for the fraction class so that it checks to make sure that the numerator and denominator are both integers. If either is not an integer the constructor should raise an exception.
6.Devise an experiment to verify that get item and set item are O(1)O(1) for dictionaries.
7.Devise an experiment that compares the performance of the del operator on lists and dictionaries.
8.Given a list of numbers in random order, write an algorithm that works in O(nlog(n))O(nlog(n)) to find the kth smallest number in the list.
9.Implement the Queue ADT, using a list such that the rear of the queue is at the end of the list.
10.Implement a stack using linked lists.
11.Implement a queue using linked lists.
12.Consider the following list of integers: [10,9,8,7,6,5,4,3,2,1]. Show how this list is sorted by the following algorithms:
bubble sort
selection sort
insertion sort
shell sort (you decide on the increments)
merge sort
quick sort (you decide on the pivot value)
13.Consider the list of characters: ['P','Y','T','H','O','N']. Show how this list is sorted using the following algorithms:
bubble sort
selection sort
insertion sort
shell sort (you decide on the increments)
merge sort
quick sort (you decide on the pivot value)
14.In the hash table map implementation, the hash table size was chosen to be 101. If the table gets full, this needs to be increased. Re-implement the put method so that the table will automatically resize itself when the loading factor reaches a predetermined value (you can decide the value based on your assessment of load versus performance).
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
