Could someone please write this in Python Comments would be very .docx

  • No School
  • AA 1
  • 4

This preview shows page 1 - 4 out of 4 pages.

Image of page 1

Subscribe to view the full document.

Could someone please write this in Python? Comments would be very helpful. Write a function insertion_sort(head), where head is a reference to a linked list that has already been constructed. Take the linked list head and construct a linked list that is sorted in descending order. It returns the resulting sorted linked list. Important: Construct the sorted list by moving nodes over from head and inserting them into the sorted list. Do not create new list nodes while sorting. ***Please use Insertion Sort*** Programming requirements: 1. The new (sorted) list should consist of the same list nodes as in the original list, with the only difference being that the order of the list nodes is changed.
Image of page 2
2. Your code should transform the input linked llist head into the sorted linked list returned by your function without going through any intermediate data structures such as arrays (i.e., Python lists) or stacks. It is OK use a few variables to temporarily hold references into your lists, but not to construct any additional data structure.
Image of page 3

Subscribe to view the full document.

Image of page 4
  • Fall '19
  • Array data structure

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern

Ask Expert Tutors You can ask 0 bonus questions You can ask 0 questions (0 expire soon) You can ask 0 questions (will expire )
Answers in as fast as 15 minutes