Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help on #10. 1. Create a Node class that has a string called data and a pointer to the next Node called next.

image text in transcribedimage text in transcribedimage text in transcribedI need help on #10.

1. Create a Node class that has a string called data and a pointer to the next Node called next. Note: Because we want Nodes to be useful for many things, we'll use Strings and use int/ double parsing where necessary. This is inefficient both due to the extra processing of parsing and the much higher memory usage of Strings compared to ints and doubles. public class Node{ public String data; public Node next; } 2. Create a function node ToString() that takes a head Node (which may be null). The returned String should look something like this: [A, =>] [B, =>] [C, null] public static String nodeToString (Node h) public static String nodeToString(Node h){ if(h == null){ return "null"; } String rv = ""; while(h != null){ if(h.next != null) rv += "[" + h.data + ", =>]"; else ry += "[" + h.data + ", null]"; h = h.next; } return rv; } 3. Create a function get() that takes a head Node and an int index. get() should return the String in the nth Node. Start indexing at 0. If the index is out of bounds, return null. public static String get (Node h, int index) public static String get(Node h, int index) { String ans = ""; Node c = h; for(int i = 0; c != null && i

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 And Expert Systems Applications 33rd International Conference Dexa 2022 Vienna Austria August 22 24 2022 Proceedings Part 1 Lncs 13426

Authors: Christine Strauss ,Alfredo Cuzzocrea ,Gabriele Kotsis ,A Min Tjoa ,Ismail Khalil

1st Edition

3031124227, 978-3031124228

More Books

Students also viewed these Databases questions

Question

6 in modern advanced accounting in canada sixth edition chp 11

Answered: 1 week ago

Question

7. Explain why retirees may be valuable as part-time employees.

Answered: 1 week ago