Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assignment #3 consists of two parts. You must complete both parts to receive full points. PART A: Implement the following method as a new static

Assignment #3 consists of two parts. You must complete both parts to receive full points.

PART A:

Implement the following method as a new static method for the IntNode class. (Use the usual IntNode class with instance variables called data and link.)

public static int count42s(IntNode head)

// Precondition: head is the head reference of a linked list.

// The list might be empty or it might be non-empty.

// Postcondition: The return value is the number of occurrences

// of 42 in the data field of a node on the linked list.

// The list itself is unchanged.

PART B:

Suppose that p, q, and r are all references to nodes in a linked list with 15 nodes. The variable p refers to the first node, q refers to the 8th node, and r refers to the last node. Write a few lines of code that will make a new copy of the list. You code should set THREE new variables called x, y, and z so that: x refers to the first node of the copy, y refers to the 8th node of the copy, and z refers to the last node of the copy. Your code may NOT contain any loops, but it can use the other IntNode methods.

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

Databases On The Web Designing And Programming For Network Access

Authors: Patricia Ju

1st Edition

1558515100, 978-1558515109

More Books

Students also viewed these Databases questions