Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private int recur(int count) {
- if (count > 0) {
- System.out.println(count);
- return count + recur(--count); // this value will be in stack.
- }
- return count;
- }
- private void divide(int low, int high) {
- System.out.println("Divide => Low: "+ low +" High: "+ high);
- if (low < high) {
- int middle = (low + high) / 2;
- divide(low, middle); // {0,7},{0,3}, {0,1} ;
- divide(middle + 1, high); // {0,0}; high = 1; // 2nd divide
- combine(low, middle, high);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement