Call us 24/7: + 1(925)399 0085

Get your paper done by an expert

No matter what kind of academic paper you need, it is simple and secure to hire an essay writer for a price you can afford at StudyAcer. Save more time for yourself.

WhatsApp + 1(925)399 0085
$ 10
  • bibliography
  • title page
  • revisions
per page
19 k happy customers
4.7 out of 5 satisfaction rate
27 writers active

Recursion program




  1. Write a 
    public static function named 
    power that takes in two integers, 
    a and 
    b, and returns 
    b, the first argument to the power of the second argument. You may 
    NOT use 
    Math.pow(), because that would be boring.
  2. The base case in this method is when the second argument is 0: 
    n^0 = 1, by definition.
  3. Hint: 3^5 = 3*(3^4)
  4. Why is recursion not the best solution for this problem? If you do not know, ask a TA.
    1. Create a similar method named 
      power2 that is functionally identical but does not use recursion. It should still NOT use 


  1. Write a 
    public static function named 
    fileCount that takes as input a directory (as a File object) and returns the total number of files in all sub-directories
    1. Directories count as files, too.
  2. Your method should look through all files and sub-directories in the directory that was passed in. While searching through the directory, use the method to check if the File you are looking at is a file or directory. If it is a normal file, count it. If it is a directory, count it and use a recursive call to count its contents.
  3. Hint: 
    1. What is the base case?
    2. What is the recursive step?
    3. What is the combination?
  4. You should consult the API for more information.
  5. The following directory structure has 14 files:
root_dir          1_x000D_
+--dir            2_x000D_
|  +--file        3_x000D_
+--dir            4_x000D_
|  +--dir         5_x000D_
|  |  +--dir      6_x000D_
|  |  |  +--file  7_x000D_
|  |  +--file     8_x000D_
|  +--file        9_x000D_
+--dir           10_x000D_
|  +--dir        11_x000D_
|  |  +--file    12_x000D_
|  +--file       13_x000D_
+--file          14


  1. Write a 
    public static function named 
    hanoi that recursively solves the Tower of Hanoi puzzle (see the description below).
  2. Your function should take 1 integer and 3 chars as input (in this order): 
    1. n is the number of disks.
    2. src (source), 
      dest (destination), and 
      aux (auxiliary) are tower letters.
    3. For example, to solve the 3 disk puzzle, you would call 
      1. hanoi(3,'A','C','B'); means “move 3 disks from tower A to tower C using tower B”
  3. Your function should print the solution to the puzzle to standard output in the following format:
    1. “move [disk] from [tower1] to [tower2]”
      1. [disk] is the number of the disk being moved. Disks are numbered 1 to 
        n, 1 being the smallest and 
        n being the largest.
      2. [tower1] is the letter of the tower 
        from which the disk is being moved.
      3. [tower2] is the letter of the tower 
        to which the disk is being moved.
    2. For example: “move 1 from A to C” is the first step of solving the 3 disk problem.
    3. Print each step on its own line.
  4. The base case is the 0-disk problem, for which nothing must be done (just return).
    1. What is the recursive step?
    2. What is the combination?
  5. Hints:
    1. Solve the puzzle by hand (
      one of many online versions or 
    2. Divide and Conquer.
      1. How do you use the solution to the 1-disk problem to help you solve the 2-disk problem? 
      2. How about using the 2-disk solution to solve the 3-disk problem? 
      3. And so on.
    3. The whole function is just 5 lines of code.
      1. 2 of these are the base case
      2. The other 3 are the steps to use the (n-1)-disk solution to solve the n-disk problem.

About the Tower of Hanoi

There is a temple in Kashi Vishwanath which contains a large room with three time-worn posts, on which are stacked 64 golden disks. Brahmin priests, acting out the command of an ancient prophecy, have been moving these disks, in accordance with the immutable rules of the Brahma, since that time. When the last move of the puzzle is completed, the world will end. Despite the location of the legendary temple, the puzzle is most often called the Tower of Hanoi.

The objective of the puzzle is to move the entire stack of disks from the first post to the third post, obeying the following simple rules:

  1. Only one disk may be moved at a time.
  2. Each move consists of taking the upper disk from one of the stacks and placing it on top of another stack.
  3. No disk may be placed on top of a smaller disk.


  1. Figure out the pattern from the table below.
  2. Write a 
    public static function named 
    mysterySeries that take integers 
    i and 
    j as input and returns the (
    j)-th mystery number (the number in the 
    i-th row and 
    j-th column).
    1. mysterySeries(6,2) should return 15
  3. Base Cases:
    1. If 
      i < 0 or 
      j < 0 or 
      i < 
      j, then A(
      j) = 0
    2. The above 3 base cases are 
      not sufficient, what other base case(s) do you need?
  4. Hint: Each element of the 
    i-th row can be computed from elements in the (
    i-1)-th row.
A(i,j … 
10  10     
15  20  15   
…  …  …  …  …  …  …  …  … 

Our guarantees

Study Acers provides students with tutoring and help them save time, and excel in their courses. Students LOVE us!No matter what kind of essay paper you need, it is simple and secure to hire an essay writer for a price you can afford at StudyAcers. Save more time for yourself. Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Our Homework Writing Disciplines

With a highly diverse team in almost all academic fields including: