(9 marks) Complete the following methods in the class MyLinkedList based the description provided. b. on i. (3 marks) size()

(9 marks) Complete the following methods in the class MyLinkedList based the description provided. b. on i. (3 marks) size() return the number of items in the list. i. (3 marks) count Positives (): return the number of positive values in the list ii. (3 marks) (Advanced) reverse the order of the items in reverse ( the list. If the list is 10 90, then after calling the – 70 – 20 -> method, it should become 90 – 70 20 10. -> -> public class MyLinkedList private Node head; 2 3 public int size 4 return 0 /to be completed 6 7 public int countPositives () return 0 //to be completed } 10 11 public void reverse () //to be completed 12 13 } 14 15 public void addToFront ( int val) { 16 new Node (val, head); Node node 17 head node 18 19 } 20



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *