Question: Write a recursive method named digitsSorted that takes an integer as a parameter and returns true if the digits of the integer are sorted and

 Write a recursive method named digitsSorted that takes an integer as

Write a recursive method named digitsSorted that takes an integer as a parameter and returns true if the digits of the integer are sorted and false otherwise. The digits must be sorted in non-decreasing order (i.e. increasing order with duplicate digits allowed) when read from left to right. An integer that consists of a single digit is sorted by definition. The method should be also able to handle negative numbers. Negative numbers are also considered sorted if their digits are in non-decreasing order The following table shows several calls to your method and their expected return values: Call Value Returned true true true digitsSorted(D) digitsSorted (2345) digitsSorted(-2345) digitsSorted (22334455) true digitsSorted (-5) digitsSorted (4321) digitsSorted (24378) digitsSorted (21) digitsSorted(-33331) false true false false false Constraints: Do not declare any global variables. Do not use any loops; you must use recursion. Do not use any auxiliary data structures like ArrayList, TreeMap, TreeSet, array, etc. Also do not solve this problem using a string. You can declare as many primitive variables like ints as you like. You are allowed to define other "helper" methods if you like; they are subject to these same constraints

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!