Fill in Order Details

  • Submit paper details for free using our simple order form

Make Payment Securely

  • Add funds to your account. There are no upfront payments. The writer will only be paid once you have approved your paper

Writing Process

  • The best qualified expert writer is assigned to work on your order
  • Your paper is written to standard and delivered as per your instructions

Download your paper

  • Download the completed paper from your online account or your email
  • You can request a plagiarism and quality report along with your paper

Recursion program

Problems

 

power

  1. Write a 
    public static function named 
    power that takes in two integers, 
    a and 
    b, and returns 
    a^
    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 
      Math.pow().

fileCount

  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 
    java.io.File.isDirectory() 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 
    java.io.File API for more information.
  5. The following directory structure has 14 files:
root_dir          1
+--dir            2
|  +--file        3
+--dir            4
|  +--dir         5
|  |  +--dir      6
|  |  |  +--file  7
|  |  +--file     8
|  +--file        9
+--dir           10
|  +--dir        11
|  |  +--file    12
|  +--file       13
+--file          14

hanoi

  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): 
    n
    src
    dest
    aux.
    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 
      hanoi(3,'A','C','B');
      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 
      another).
    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.

mysterySeries

  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 (
    i,
    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(
      i,
      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   
…  …  …  …  …  …  …  …  … 

WHAT OUR CURRENT CUSTOMERS SAY

  • Google
  • Sitejabber
  • Trustpilot
Zahraa S
Zahraa S
Absolutely spot on. I have had the best experience with Elite Academic Research and all my work have scored highly. Thank you for your professionalism and using expert writers with vast and outstanding knowledge in their fields. I highly recommend any day and time.
Stuart L
Stuart L
Thanks for keeping me sane for getting everything out of the way, I’ve been stuck working more than full time and balancing the rest but I’m glad you’ve been ensuring my school work is taken care of. I'll recommend Elite Academic Research to anyone who seeks quality academic help, thank you so much!
Mindi D
Mindi D
Brilliant writers and awesome support team. You can tell by the depth of research and the quality of work delivered that the writers care deeply about delivering that perfect grade.
Samuel Y
Samuel Y
I really appreciate the work all your amazing writers do to ensure that my papers are always delivered on time and always of the highest quality. I was at a crossroads last semester and I almost dropped out of school because of the many issues that were bombarding but I am glad a friend referred me to you guys. You came up big for me and continue to do so. I just wish I knew about your services earlier.
Cindy L
Cindy L
You can't fault the paper quality and speed of delivery. I have been using these guys for the past 3 years and I not even once have they ever failed me. They deliver properly researched papers way ahead of time. Each time I think I have had the best their professional writers surprise me with even better quality work. Elite Academic Research is a true Gem among essay writing companies.
Got an A and plagiarism percent was less than 10%! Thanks!

ORDER NOW


Consider Your Assignments Done

“All my friends and I are getting help from eliteacademicresearch. It’s every college student’s best kept secret!”

Jermaine Byrant
BSN

“I was apprehensive at first. But I must say it was a great experience and well worth the price. I got an A!”

Nicole Johnson
Finance & Economics

Our Top Experts

See Why Our Clients Hire Us Again And Again!


OVER

10.3k
Reviews

RATING
4.89/5
Average

YEARS
13
Mastery

Success Guarantee

When you order form the best, some of your greatest problems as a student are solved!

Reliable

Professional

Affordable

Quick

Using this writing service is legal and is not prohibited by any law, university or college policies. Services of Elite Academic Research are provided for research and study purposes only with the intent to help students improve their writing and academic experience. We do not condone or encourage cheating, academic dishonesty, or any form of plagiarism. Our original, plagiarism-free, zero-AI expert samples should only be used as references. It is your responsibility to cite any outside sources appropriately. This service will be useful for students looking for quick, reliable, and efficient online class-help on a variety of topics.