Assignment 4 Solution

$24.99 $18.99

Question 1 This code is saved in 4_1.py. The program contains 2 classes: Node, SinglyLinkedList. The SinglyLinkedList contains a method named recursive_count which recursively counts the number of nodes in a singly linked list. The input of the recursive_count function should be a reference pointing to the first node of the linked list. The output…

5/5 – (2 votes)

You’ll get a: zip file solution

 

Description

5/5 – (2 votes)

Question 1

  1. This code is saved in 4_1.py.

  1. The program contains 2 classes: Node, SinglyLinkedList. The SinglyLinkedList contains a method named recursive_count which recursively counts the number of nodes in a singly linked list.

  1. The input of the recursive_count function should be a reference pointing to the first node of the linked list. The output of the function should be the number of nodes in that linked list.

  1. Execute as followings:

Question 2

  1. This code is saved in 4_2.py.

  1. The program contains 2 classes: Node, SinglyLinkedList. The SinglyLinkedList contains a method named quick_sort which uses quick sort algorithm to sort over a singly linked list.

  1. The input of your function should be a reference pointing to the first node of a linked list, and the output of your function should also be a reference to the first node of a linked list, in which the data have been sorted into the ascending order.

  2. Execute as followings:

Question 3

  1. This code is saved in 4_3.py.

  1. The program prompts user to input the number of disks in Tower of Hanoi game. After that, it will print out the steps to move all the disks from rod A to rod C via rod B.

  1. The input can be anything, but only a positive integer number input can be executed.

  2. Execute as followings:

Assignment 4 Solution
$24.99 $18.99