Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assume class SimpleLinkedList is defined as follows: public class SimpleLinked List { protected Node first; protected Node last; protected int count; public SimpleLinkedList() { first

image text in transcribed
image text in transcribed
Assume class SimpleLinkedList is defined as follows: public class SimpleLinked List { protected Node first; protected Node last; protected int count; public SimpleLinkedList() { first = null; last = null; count = 0; } public boolean isEmpty() { return first == null; } public int length({ return count; } public void print() { Node current = first; while (current != null) { System.out.print(current.info + " "); current = current.link; } } public boolean search(int searchinfo) { Node current = first; boolean found = false; while (current I= null && Ifound) { if (current.info uu searchinfo) { found=true; } else { current = current.link: MacBook current = current.link: 3 return found; ) public void insert(int newinfo) { Node newNode = new Node(newinfo); if (isEmpty) { first = last = newNode; } else { newNode.link = first; first = newNode; } count++; ) Add a method to Simplelinked List that prints the numbers in the nodes that are in odd positions in a linked list: public void printOddNodesElements() { for the toolhor press Alt+F10 (PC) or ALT+FN+F10 (Mac)

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

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions

Question

differentiate the function ( x + 1 ) / ( x ^ 3 + x - 6 )

Answered: 1 week ago