Answered step by step
Verified Expert Solution
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
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.getDatumStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started