Answered step by step
Verified Expert Solution
Question
1 Approved Answer
111111 File: useArraysAndLinkedNodes.py Author: Derrf, Seitz This program exercises arrays and linked nodes. The following files must be in the same folder: arrays.py node.py
111111 File: useArraysAndLinkedNodes.py Author: Derrf, Seitz This program exercises arrays and linked nodes. The following files must be in the same folder: arrays.py node.py www. #Replace with your name. #Replace any " " comments with your own code statement (s) # to accomplish the specified task. # DO NOT CHANGE ANY OTHER CODE. from arrays import Array from node import Node # Part 1: #This function prints a linked list of nodes. # Parameters: head a reference to the first node in the linked list. def printLinkedList (head): #Print the linked list with each nodes's data on a separate line. # You must use some form of a loop to print the linked list. # # Here is the array: theArray - Array (10) for i in range (len (theArray)) : theArray[i] = 1 + 1 # Print the array: print ("The array:") print (theArray) print () # blank line #Here is the array: theArray Array (10) for i in range (len (theArray)) : theArray[i]=i+1 #Print the array: print ("The array:") print (theArray) print () # blank line- # You must use these variables in your code: Node (theArray [0], None). head tail = head # Part 2: # Copy the array items to a linked list of nodes: # The linked list must consist of Node class items. # You must use some form of a loop to create the linked list. # print ("After creating the list from the array items:") printLinkedList (head) print () # blank line. # Part 3: # Add a node with the value 99 to the end of the list: # print ("After adding 99 to the end of the list: ") printLinkedList (head) print () # blank line. # Part 4: # Add a node with the value 55 after the node with the value 5: # You must go through the list until you arrive at the 5, #then link in the new node correctly. # print ("After adding 55 after the node with the value 5:") printLinkedList (head)
Step by Step Solution
★★★★★
3.51 Rating (171 Votes )
There are 3 Steps involved in it
Step: 1
Program Screenshot for Indentation Reference Sample Output Program code to copy File useArraysAndLinkedNodespyAuthor Derrf Seitz This program exercise...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started