See attached file for full problem description.
1. Reason why C++ is longer:
C++ has much less built-in functions defined than Java. So every utility classes, such as stack, need to be build by the application. So the application program needs to define the stack class, including every utility functions (methods) associated with this class, such as push(), pop(), peek() and search(). On the other hand, Java has a built-in package
ava.util that defines the utility classes ...
This job explains between two programming languages.