REQUIREMENTS: 1. 2. 3. Using Python, you will write a program called singly-linked-list-arrays.py that implements an ordered singly-linked list using arrays. The data items in your ordered singly-linked list will consist of first names. For example: Adam, Eve, Frank, Mark, Vanessa, etc. Be sure to include the following linked list operations in your Python program: . . . . GetNode(FreeNodes) returns the index of the first available (free) node as indicated in the FreeNodes boolean array. If there are no available (free) nodes, then returns - InsertNode(Data, Link, FreeNodes, new Node, head Ptr) inserts a newNode into the linked list, referenced by headPtr, as represented using the Data and Link arrays. The index of the corresponding FreeNode array element is assigned the value of False, indicating that this node is no longer considered "free." Returns +1 if successfully inserted into the list, otherwise returns -1. 1. DeleteNode(Data, Link, FreeNodes, nodeToDelete, headPtr) deletes the nodeToDelete from the linked list, referenced by headPtr, as represented using the Data and Link arrays. The index of the corresponding FreeNode array element is assigned the value of True, indicating that this node is now considered "free." Returns +1 if successfully deleted, otherwise returns -1. SearchList(Data, Link, FreeNodes, findNode, headPtr) searches the linked list, referenced by headPtr and represented using the Data and Link arrays, for which the data value matches that of findNode. Returns the index value in the Data array of the found node. If the findNode item is not found, then the value -1 is returned. PrintLinked List(Data, Link, headPtr) prints the data values of all nodes in the singly-linked list, in order. If the linked list is empty, then prints "No items in the linked list."

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter17: Linked Lists
Section: Chapter Questions
Problem 18SA
icon
Related questions
Question
Only the simple algorithm please.
REQUIREMENTS:
1.
2.
3.
Using Python, you will write a program called singly-linked-list-arrays.py that implements an ordered singly-linked list using arrays.
The data items in your ordered singly-linked list will consist of first names. For example: Adam, Eve, Frank, Mark, Vanessa, etc.
Be sure to include the following linked list operations in your Python program:
▪
2.
3.
GetNode(FreeNodes) returns the index of the first available (free) node as indicated in the FreeNodes boolean array. If there are no available (free) nodes, then returns -
InsertNode(Data, Link, FreeNodes, new Node, headPtr) inserts a new Node into the linked list, referenced by headPtr, as represented using the Data and Link
arrays. The index of the corresponding FreeNode array element is assigned the value of False, indicating that this node is no longer considered "free." Returns +1 if
successfully inserted into the list, otherwise returns -1.
1.
DeleteNode(Data, Link, FreeNodes, nodeToDelete, headPir) deletes the nodeToDelete from the linked list, referenced by headPtr, as represented using
the Data and Link arrays. The index of the corresponding FreeNode array element is assigned the value of True, indicating that this node is now considered "free."
Returns+1 if successfully deleted, otherwise returns -1.
SearchList(Data, Link, FreeNodes, findNode, headPtr) searches the linked list, referenced by headPtr and represented using the Data and Link arrays, for which the
data value matches that of findNode. Returns the index value in the Data array of the found node. If the findNode item is not found, then the value -1 is returned.
PrintLinked List(Data, Link, headPtr) prints the data values of all nodes in the singly-linked list, in order. If the linked list is empty, then prints "No items in the linked
list."
IMPLEMENTATION DETAILS:
1.
Be sure to include your name, along with the Certificate of Authenticity, as comments at the very beginning of your Python code. Also, if you collaborated with others, be sure to state their
names as well.
Your program MUST validate user input, informing the user of invalid input data.
Your program should display the following menu (looping continuously until the user selects option E):
Enter the letter below that corresponds to the desired singly-linked list operation:
A. Insert a new item (i.e., string) into the ordered singly-linked list.
B. Delete a specified item (i.e., string) from the ordered singly-linked list.
C. Print all items (i.e., strings) in the ordered singly-linked list.
D. Print the contents of the following:
Data array
Link array
FreeNodes array
Value of headPtr
E. End program.
**Note: Your menu logic should accept options A, B, C, D, E (uppercase or lowercase). Anything other than these options should generate the following error message to the user:
Invalid option! Please enter A, B, C, D or E.
Transcribed Image Text:REQUIREMENTS: 1. 2. 3. Using Python, you will write a program called singly-linked-list-arrays.py that implements an ordered singly-linked list using arrays. The data items in your ordered singly-linked list will consist of first names. For example: Adam, Eve, Frank, Mark, Vanessa, etc. Be sure to include the following linked list operations in your Python program: ▪ 2. 3. GetNode(FreeNodes) returns the index of the first available (free) node as indicated in the FreeNodes boolean array. If there are no available (free) nodes, then returns - InsertNode(Data, Link, FreeNodes, new Node, headPtr) inserts a new Node into the linked list, referenced by headPtr, as represented using the Data and Link arrays. The index of the corresponding FreeNode array element is assigned the value of False, indicating that this node is no longer considered "free." Returns +1 if successfully inserted into the list, otherwise returns -1. 1. DeleteNode(Data, Link, FreeNodes, nodeToDelete, headPir) deletes the nodeToDelete from the linked list, referenced by headPtr, as represented using the Data and Link arrays. The index of the corresponding FreeNode array element is assigned the value of True, indicating that this node is now considered "free." Returns+1 if successfully deleted, otherwise returns -1. SearchList(Data, Link, FreeNodes, findNode, headPtr) searches the linked list, referenced by headPtr and represented using the Data and Link arrays, for which the data value matches that of findNode. Returns the index value in the Data array of the found node. If the findNode item is not found, then the value -1 is returned. PrintLinked List(Data, Link, headPtr) prints the data values of all nodes in the singly-linked list, in order. If the linked list is empty, then prints "No items in the linked list." IMPLEMENTATION DETAILS: 1. Be sure to include your name, along with the Certificate of Authenticity, as comments at the very beginning of your Python code. Also, if you collaborated with others, be sure to state their names as well. Your program MUST validate user input, informing the user of invalid input data. Your program should display the following menu (looping continuously until the user selects option E): Enter the letter below that corresponds to the desired singly-linked list operation: A. Insert a new item (i.e., string) into the ordered singly-linked list. B. Delete a specified item (i.e., string) from the ordered singly-linked list. C. Print all items (i.e., strings) in the ordered singly-linked list. D. Print the contents of the following: Data array Link array FreeNodes array Value of headPtr E. End program. **Note: Your menu logic should accept options A, B, C, D, E (uppercase or lowercase). Anything other than these options should generate the following error message to the user: Invalid option! Please enter A, B, C, D or E.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Lists
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning