Advertisement
Guest User

Untitled

a guest
Feb 27th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. private int recur(int count) {
  2. if (count > 0) {
  3. System.out.println(count);
  4. return count + recur(--count); // this value will be in stack.
  5. }
  6. return count;
  7. }
  8.  
  9. private void divide(int low, int high) {
  10. System.out.println("Divide => Low: "+ low +" High: "+ high);
  11. if (low < high) {
  12. int middle = (low + high) / 2;
  13. divide(low, middle); // {0,7},{0,3}, {0,1} ;
  14. divide(middle + 1, high); // {0,0}; high = 1; // 2nd divide
  15. combine(low, middle, high);
  16. }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement