Question: This is for programming with the java language. Please follow the instructions below. I have included the Node constructor program needed for the search program
Searching an Ordered Linked List Take a look at the Search program in your current directory. You need to add two ods to this program so that it will successfully read in 0 or more integers from the keyboard, insert each of them into a sorted linked list, and then allow the user to search for a key from your list. First off, in buildList, you will need to declare a local head pointer and flush it to null. Next, use the Scanner class to read in one or more tokens from the keyboard. You're now ready to continue reading in tokens until the end of file is reached. To simulate end of file from the keyboard, you'll use Control-D. Each token that is a number should be inserted into the linked list using the insert method. Be sure you assign the result of this method to head each time in case your new item was added to the beginning of your linked list or your list was initially empty. Finally, complete the search method that takes the head pointer and a key value, and returns true or false indicating whether your key value is present in your list. You may use iteration or recursion. Test your program using the sample run below where user input is shown in boldface. Sample Run Please input o or more values at keyboard 12 4 -1 5 3 Now printing list -1 0 2 34 5 12 What key in list are you searching for? 15 Your key was not found
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
