Develop a Doubly-Linked-List, with the given Python file A1B2.py. tailN headN JOA Each node in Doubly-Linked-List...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Develop a Doubly-Linked-List, with the given Python file A1B2.py. tailN headN JOA Each node in Doubly-Linked-List has two links: one for the next node as in singly-linked list, the other for the previous node. The head node has no previous link and the tail node has no next link. This is implemented as a Python class DLNode and given in our Python file. prevN value nextN Some operations could be done for efficiently with this Doubly-Linked-List, which require tracing backward (the previous node of the current node). o Given an uncompleted Doubly-Linked-List in A1B2.py (based on the one in our lecture notes, Llist.py), with implemented methods below: Given Operations (Class DDList) Description _init__(): appendDL (elt): displayDL (): displayBwDL(): Create and initiate a new DLL (constructor) Append/Insert element elt as a new tail Traverse & display node values, starting from head in forward order Traverse & display node values, starting from tail in backward order Complete this Doubly-Linked-List with the Extra Operations below (methods of the class): o At least one line of simple comment for each extra operation required Operations (Class DDList) getNextFwDL (refElt): elt Description Get & return (without remove) the next element of a reference element refelt, starting from head in forward order Return None if no element can be returned getPrevFwDL (refElt):elt removePrevBwDL (refElt): elt Remove & return the previous element elt of a reference element refelt, starting from head in backward order Return None if no element can be removed and returned File A1B2.py, to be modified and completed by student. O Include a given class of nodes with a value and two links (to previous and next nodes): # A1B2.py, for IDSA A1 class DLNode: # modelling a node with doubly-linked def _init__(self, inValue=None, inPrev=None, inNext=None): self.value = inValue # the node data value, default None self.prevN inPrev # the previous node, default None self.nextN = inNext # the next node, default None class DLList: # defining a class of Doubly-Linked List _init__(self): # constructor self.headN= None # the head Node self.tailN = None # the tail Node def #### Get & return (without remove) previous element of reference element refelt, starting from tail in backward order O Return None if no element can be returned ##########_STUDNET'S WORK #####⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀: # MORE DETAILS ########### END of STUDNET'S WORK #### File MA1B2.py for basic running and testing # MA1B2.py, for basic running and testing. # * DO NOT modify this given test file, except the STUDENT INFO part. # Main Testing Program from A1B2 import DLList main() DLNode value prevN nextN def main(): print("=== === A1B2, DLList program, by <Student NAME> <Student ID>===") _init__(v,p,n): DDList (Doubly-Linked) headN tailN _init__(): appendDL (elt): displayDL(): displayBwDL(): getNextFwDL(refElt): elt getPrevFwDL (refElt): elt removePrevBwDL (refElt): elt myL= DLList() myL.appendDL (11); myL.appendDL (22); myL.appendDL (33) myL.appendDL (55); myL.appendDL (77); myL.appendDL (99) print("\n--- 1. List with Insert items <11,22,33,55,77,99>---") myl.displayBwDL () myl.displayDL() print (f" ------ <CHECK> getNextFwDL (55), elt:{myL.getNextFwDL (55)}") print (f" ------ <CHECK> get PrevBwDL (55), elt:{myL.getPrevBwDL (55)}") print (f"\n ------2. <CHECK> remove PrevBwDLBw (55), elt:{myL.remove PrevBwDL (55)}") myl.displayDL() myl.displayBwDL () print("\n=== Program ends ===\n") Sample console display output of executing the main testing program MA1B2.py === === A1B2, DLList program, by <Student NAME> <Student ID>=== --- 1. List with Insert items <11,22,33,55,77,99>--- <<< DOUBLY-Linked-List Display, Backwards: << FROM ... tail <99>, head <11> < 99 < 77 < 55 < 33 < 22 < 11 >>> DOUBLY-Linked-List Display: > head <11>, tail <99>: ... > 11 > 22 > 33 > 55 > 77 > 99 --- <CHECK> ------ <CHECK> --- getNextFwDL (55), elt:77 getPrevBwDL (55), elt:33 ------2. <CHECK> removePrevBwDLBw (55), elt:33 <<< DOUBLY-Linked-List Display, Backwards: << FROM ... tail <99>, head <11> < 99 < 77 55 < 22 < 11 >>> DOUBLY-Linked-List Display: > ... head <11>, tail <99>: > 11 > 22 > 55 > 77 > 99 === Program ends === Submission and Assessment o Check and follow requirements and instructions, including to follow the required naming of files. o Run, Debug, Test and Evaluate your program based on the requirements. o Submit ALL related files to SOUL: o A1B1.py, MA1B1.py o A1B2.py, MA1B2.py o Do NOT compress/zip or rename the files. Submission work not following requirements may be penalized or not be assessed. o Students are responsible for ensuring that their files are submitted successfully and properly (e.g. submit the right file to the right submission item on SOUL, etc.). o Lecturers will not handle or inform students by any means if improper file was submitted, such as submitted file was corrupted or sent wrongly with an old version. o It is highly recommended that students should download the uploaded files after submission, to double-check their submitted work before deadline. o Students should be able to finish this assignment within 1-3 hours. o Students should well-plan their time and schedule to complete the assignment, review the related course materials, finish and submit the assignment within the first 3 days after the assignment has been released. o Students who fail to follow take their own risk of improper submission or even missing the submission deadline, even though the given submission period and set deadline may be much longer than what is required to finish the assignment. * Remarks: More testing may be performed during assessment based on the requirements, apart from the given testing files. O Develop a Doubly-Linked-List, with the given Python file A1B2.py. tailN headN JOA Each node in Doubly-Linked-List has two links: one for the next node as in singly-linked list, the other for the previous node. The head node has no previous link and the tail node has no next link. This is implemented as a Python class DLNode and given in our Python file. prevN value nextN Some operations could be done for efficiently with this Doubly-Linked-List, which require tracing backward (the previous node of the current node). o Given an uncompleted Doubly-Linked-List in A1B2.py (based on the one in our lecture notes, Llist.py), with implemented methods below: Given Operations (Class DDList) Description _init__(): appendDL (elt): displayDL (): displayBwDL(): Create and initiate a new DLL (constructor) Append/Insert element elt as a new tail Traverse & display node values, starting from head in forward order Traverse & display node values, starting from tail in backward order Complete this Doubly-Linked-List with the Extra Operations below (methods of the class): o At least one line of simple comment for each extra operation required Operations (Class DDList) getNextFwDL (refElt): elt Description Get & return (without remove) the next element of a reference element refelt, starting from head in forward order Return None if no element can be returned getPrevFwDL (refElt):elt removePrevBwDL (refElt): elt Remove & return the previous element elt of a reference element refelt, starting from head in backward order Return None if no element can be removed and returned File A1B2.py, to be modified and completed by student. O Include a given class of nodes with a value and two links (to previous and next nodes): # A1B2.py, for IDSA A1 class DLNode: # modelling a node with doubly-linked def _init__(self, inValue=None, inPrev=None, inNext=None): self.value = inValue # the node data value, default None self.prevN inPrev # the previous node, default None self.nextN = inNext # the next node, default None class DLList: # defining a class of Doubly-Linked List _init__(self): # constructor self.headN= None # the head Node self.tailN = None # the tail Node def #### Get & return (without remove) previous element of reference element refelt, starting from tail in backward order O Return None if no element can be returned ##########_STUDNET'S WORK #####⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀: # MORE DETAILS ########### END of STUDNET'S WORK #### File MA1B2.py for basic running and testing # MA1B2.py, for basic running and testing. # * DO NOT modify this given test file, except the STUDENT INFO part. # Main Testing Program from A1B2 import DLList main() DLNode value prevN nextN def main(): print("=== === A1B2, DLList program, by <Student NAME> <Student ID>===") _init__(v,p,n): DDList (Doubly-Linked) headN tailN _init__(): appendDL (elt): displayDL(): displayBwDL(): getNextFwDL(refElt): elt getPrevFwDL (refElt): elt removePrevBwDL (refElt): elt myL= DLList() myL.appendDL (11); myL.appendDL (22); myL.appendDL (33) myL.appendDL (55); myL.appendDL (77); myL.appendDL (99) print("\n--- 1. List with Insert items <11,22,33,55,77,99>---") myl.displayBwDL () myl.displayDL() print (f" ------ <CHECK> getNextFwDL (55), elt:{myL.getNextFwDL (55)}") print (f" ------ <CHECK> get PrevBwDL (55), elt:{myL.getPrevBwDL (55)}") print (f"\n ------2. <CHECK> remove PrevBwDLBw (55), elt:{myL.remove PrevBwDL (55)}") myl.displayDL() myl.displayBwDL () print("\n=== Program ends ===\n") Sample console display output of executing the main testing program MA1B2.py === === A1B2, DLList program, by <Student NAME> <Student ID>=== --- 1. List with Insert items <11,22,33,55,77,99>--- <<< DOUBLY-Linked-List Display, Backwards: << FROM ... tail <99>, head <11> < 99 < 77 < 55 < 33 < 22 < 11 >>> DOUBLY-Linked-List Display: > head <11>, tail <99>: ... > 11 > 22 > 33 > 55 > 77 > 99 --- <CHECK> ------ <CHECK> --- getNextFwDL (55), elt:77 getPrevBwDL (55), elt:33 ------2. <CHECK> removePrevBwDLBw (55), elt:33 <<< DOUBLY-Linked-List Display, Backwards: << FROM ... tail <99>, head <11> < 99 < 77 55 < 22 < 11 >>> DOUBLY-Linked-List Display: > ... head <11>, tail <99>: > 11 > 22 > 55 > 77 > 99 === Program ends === Submission and Assessment o Check and follow requirements and instructions, including to follow the required naming of files. o Run, Debug, Test and Evaluate your program based on the requirements. o Submit ALL related files to SOUL: o A1B1.py, MA1B1.py o A1B2.py, MA1B2.py o Do NOT compress/zip or rename the files. Submission work not following requirements may be penalized or not be assessed. o Students are responsible for ensuring that their files are submitted successfully and properly (e.g. submit the right file to the right submission item on SOUL, etc.). o Lecturers will not handle or inform students by any means if improper file was submitted, such as submitted file was corrupted or sent wrongly with an old version. o It is highly recommended that students should download the uploaded files after submission, to double-check their submitted work before deadline. o Students should be able to finish this assignment within 1-3 hours. o Students should well-plan their time and schedule to complete the assignment, review the related course materials, finish and submit the assignment within the first 3 days after the assignment has been released. o Students who fail to follow take their own risk of improper submission or even missing the submission deadline, even though the given submission period and set deadline may be much longer than what is required to finish the assignment. * Remarks: More testing may be performed during assessment based on the requirements, apart from the given testing files. O
Expert Answer:
Answer rating: 100% (QA)
You are tasked with completing a doublylinked list implementation in Python The given code snippets provide the basic structure for the DLNode and DLL... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
Professor Fortun agrees with Neil deGrasse Tyson about many scientific and political issues, and their intersections, and at the same time argues that his definition of "science" is too abstract and...
-
Knoko Systems is considering a capital budgeting project with a life of five years that requires an outlay of $90,000. It has free cash flows each period as shown in the following distribution:...
-
The following are the financial statements of Nosker Company. NOSKER COMPANY Income Statement For the Year Ended December 31, 2019 Sales revenue.....................................$242,000 Cost of...
-
Sarah is a buyer for a department store. A supplier offers her a 5 percent discount if she triples her usual order quantity. Which of the following best explains why Sarah should take the deal? a....
-
Contrast the different steps that are required in reviewing internal controls under the second standard of field work between a manual and an EDP system.
-
In early July 2012, Dr. Elaine Matthews separated from her husband of some years. She maintained full custody of the couple's only child, a seven-year-old girl. Since May 1, 1998, Dr. Matthews had...
-
Dr. Foot has been using the name "ACHILLES PILLOW" for his "medical shoe" for the last five years. He wants to register ACHILLES PILLOW as a domain name for his web site. A "whois" search has,...
-
Grimes Corporation began business in 2017 and incurred losses for its first two years. In 2019, it became profitable. The following table shows Grimess taxable income before consideration of its...
-
One futures corn contract commits the buyer to purchase 5000 bushels of corn. Suppose that you purchase a May Corn contract at $670/bushel two days ago on November 14 and plan to close the position...
-
Process Costing Use this lecture outline/guide to add notes from your reading under each topic. Include references to examples, exercises and problems that illustrate the concept. 1. What is process...
-
On January 1, 2022, Illini Company borrowed $20,000 from a local bank by signing a two-month 12% note. Interest was payable at maturity on February 28, 2022. Based on the information provided, please...
-
It is said that one of the weaknesses of the accounting rate of return is that it operates on income and not cash flows. Often, as a result, companies will use net present value analysis. If Company...
-
Conduct an analysis of its effect on the accounting financial statements. Income statement Lease Technical corrections Answer the following questions: What are FASBs and what role do they play with...
-
Kimberly Wellington, CPA, an accountant at Advanced Macro Device Corporation has been asked to determine the amount of Applied MOH for Job #101. She was provided with the information below,...
-
Explain in details the with two citations or references to support your explanation or sources. Explain the four major dimensions of job design plus job specialization and job descriptions. Describe...
-
After looking at the resources, explain what a spirit image is. Why might looking at a god and/or a human in terms of their spirit be helpful if you want to eliminate some of the divisions between...
-
Loebuck Grocery orders milk from a dairy on a weekly basis. The manager of the store has developed the following probability distribution for demand per week (in cases): Demand (cases) .........
-
Maggie Attaberry is a nurse on the evening shift from 10:00 P.M. to 6:00 A.M. at Community Hospital. She has 15 patients for whom she is responsible in her area. She averages two calls from each of...
-
Jay Seago is suing the manufacturer of his car for $3.5 million because of a defect that he believes caused him to have an accident. The accident kept him out of work for a year. The company has...
-
The following data relate to the manufacturing activities of MilTech company during November: 1. Sales $400,000 2. Purchases $60,700 3. Expenses include: Light and power for manufacturing: $2,700 ...
-
Continuing problem 6, CardioMeds cost accountants have identified cost totals for the periods production support activities and other overhead. The table below provides this information, along with...
-
Which are the main cost types in inventory valuation for manufacturing companies? What are the criteria for their classification?
Study smarter with the SolutionInn App