Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Use JavaScript classes to create a new type called LinkedList. Since a linked list is made up of nodes, we also want to create a
Use JavaScript classes to create a new type called LinkedList. Since a linked list is made up of nodes, we also want to create a second type, Node, which defines all the nodes for our list. Create a class called Node with a constructor that takes the following variables as parameters and sets them as properties o val o next Create a class called LinkedList that takes no parameters, but declares and initializes the following property o head Create a prototype method called insert in the LinkedList class . This method takes one parameter, val, which contains the value for the new node being inserted into the list . This method inserts the new node at the end of the list Create a prototype method called find in the LinkedList class . This method takes one parameter, val, which contains the value we are searching for in the linked list . This method returns the node that contains the value, if found, otherwise, it returns null
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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