Question: X 1 X 1 2 2 0 : Complete method countNodes Define a recursive method countNodes ( ) that counts all the nodes in the
XX: Complete method countNodes
Define a recursive method countNodes that counts all the nodes in the tree. Returns the number of nodes.
Your Answer:
int countNodesBinaryNode root
Use these two interfaces to solve this problem.
public interface QueueADT
public void clear;
public boolean enqueueE it;
public E dequeue;
public E frontValue;
public int numElements;
public boolean isEmpty;
interface StackADT
public void clear;
public boolean pushE it;
public E pop;
public E topValue;
public int numElements;
public boolean isEmpty;
Write a method to remove all of the elements from the 'queue' one by one and add them to a newly created stack use a StackArray and push the values in the stack. Return this stack. If queue is null, then just return an empty stack. Make sure you use the interfaces from above.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
