Home / Expert Answers / Computer Science / in-python-code-nbsp-class-can-be-anything-or-fruit-class-1-in-linkedlist-class-that-we-implemented-pa972

(Solved): in python code  class can be anything or fruit class 1. In Linkedlist class that we implemented ...



in python code 
1. In Linkedlist class that we implemented in our tutorial add following two methods, def insert after yaluelself, data, afte

a) write A Bython presram to sort a list of elewents is ing the selection sort alsoritha.
Wote it The selection sort ingroves

class can be anything or fruit class
1. In Linkedlist class that we implemented in our tutorial add following two methods, def insert after yaluelself, data, after, data to insert: Search for first occurance of data_after value in linked list Now insert data_to_insert after data_after node def remove by_value(self, data): # Remove first node that contains data Now make following calls, 11 - Linkedisist() 11. insert- 11. PRint 11. Ansent 11. print ( ) 12. remave 11. print() 11. nemave 11. print() 11. remove - by yalue("banana") 11. remove_by_value("mango") 11. remove-by_yalue ("apple") 11. remove_by_value("grapes") a) write A Bython presram to sort a list of elewents is ing the selection sort alsoritha. Wote it The selection sort ingroves on the bubble sort by making only one exchange for every pass through the list. Sarple Datat \( [14,46,43,21,51,41,45,21,70] \) Expected aesult: \( \{14,27,27,41,43,45,46,57,70\} \) b) Write a Python progras to sort a list of elcants using the insertion sort alsorithe. note i According to wikipedia "insertion sort is a simple sorting algarith that builds the final sorted array (or 1 ist) one iten at a tine. It is mich less efficient on large Hists, than more advanced algorithes such as quicksort, hespsort, or ange sort," sample pata: \( [14,46,4), 28,57,41,45,22,19] \) Expected Result \( 4[14,21,27,41,43,45,46,57,70] \)


We have an Answer from Expert

View Expert Answer

Expert Answer


Selection sort: code: def selectionSort(nlist): for x in range(len(nlist)-1,0,-1): maxpos=0 for location in range(1,x+1): if nlist[location]>nlist[maxpos]: maxpos = location temp = nlist[x] nlist[x] = nlist[maxpos] nlist[maxpos] = temp nlist = [14,46
We have an Answer from Expert

Buy This Answer $5

Place Order

We Provide Services Across The Globe