Question:
(a) Write down the class 'ListNode' to contain the following:-
(i) variable data of type Object
(ii) variable next of type ListNode
(iii) an overloaded constructor one parameter of type Object which assigns value 'o' to Object and value 'null' to ListNode
(iv) an overloaded constructor two parameters, the first parameter of type Object and the second parameter of type ListNode; the constructor assigns value 'o' to variable data and value 'nextNode' to variable next
(v) method getObject which returns a reference to the Object in the current node
(vi) method getNext which returns the next node
(b) Describe how a stack can be implemented in Java using linked list as base class.
(c) Use the binary tree given below to write down the paths when traversing the tree:-
(i) inorder
(ii) preorder
(iii) postorder