Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please solve the 2 of them using java Problem Msert a node at a specific position in a linked list. Write a method that inserts

please solve the 2 of them using java image text in transcribed
Problem Msert a node at a specific position in a linked list. Write a method that inserts a node at a specific position of the singly linked list. A position of o indicates head, a position of 1 indicates one node away from the head and so on. The head node may be null meaning that the initial list is empty. As an example, if your list starts as 1 -> 2 - > 3 and you want to insert a node at position 2 with element = 4, your new list should be 1->2->4->3 Public void insertAtPos( E e, int position) Problem 2: Write a method called printList() and add it to class Singly LinkedList. This method is used to output the elements of the linked list. Then write a main program to create a linked list and test the printList method above (sample output is shown below) Output - SL Problem1 (run) Calling syList.addrizst (10) Calling myList.addlast (20) Calling my ist.addFirss (30) Printing list

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions