Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please answer 3 a,b,c 3. 10 points each. Consider the following class definitions (virtually identical to those used in class) class IntNode f int datum

please answer 3 a,b,c

image text in transcribed

3. 10 points each. Consider the following class definitions (virtually identical to those used in class) class IntNode f int datum IntNode next; // datum to be stored // next item in list return datum h public int getDatun() public void setDatum (int which) datum which; ) public IntNode getNext) public IntNode setNext (IntNode which) return next; h { next which; } class LinkedList ( IntNode head // first item in the list; public LinkedList) head null;h Each of the following methods is a member of the LinkedList class. All the methods compile correctly; however, they do not function as described in their headers. What is wrong? How would you fix them (a) // This method counts the number of items in the list public int length O int count 1; IntNode current head while (current, getNext() != null) { current-getNext(); current count++ return count; (b) // This method places "target" at the front of the list public void prepend (int target) I IntNode newNode new IntKode(); newNode.setDatun(target) headnewNode newNode.setNext (head) (c) // This method searches a sorted list for target." // Assumption all numbers in the list are sorted // from small to large public boolean search (int target) if (head - null) return false; IntNode vhile (current.getDatum

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

Records And Database Management

Authors: Jeffrey R Stewart Ed D, Judith S Greene, Judith A Hickey

4th Edition

0070614741, 9780070614741

More Books

Students also viewed these Databases questions

Question

I am paid fairly for the work I do.

Answered: 1 week ago

Question

I receive the training I need to do my job well.

Answered: 1 week ago