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.power2
that is functionally identical but does not use recursion. It should still NOT use Math.pow()
.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-directoriesjava.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.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
public static
function named hanoi
that recursively solves the Tower of Hanoi puzzle (see the description below).hanoi(3,'A','C','B');
hanoi(3,'A','C','B');
means “move 3 disks from tower A to tower C using tower B”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:
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).mysterySeries(6,2)
should return 15A(i,j) | 0 | 1 | 2 | 3 | 4 | 5 | 6 | … |
---|---|---|---|---|---|---|---|---|
0 | 1 | |||||||
1 | 1 | 1 | ||||||
2 | 1 | 2 | 1 | |||||
3 | 1 | 3 | 3 | 1 | ||||
4 | 1 | 4 | 6 | 4 | 1 | |||
5 | 1 | 5 | 10 | 10 | 5 | 1 | ||
6 | 1 | 6 | 15 | 20 | 15 | 6 | 1 | |
… | … | … | … | … | … | … | … | … |
Our Advantages
Plagiarism Free Papers
All our papers are original and written from scratch. We will email you a plagiarism report alongside your completed paper once done.
Free Revisions
All papers are submitted ahead of time. We do this to allow you time to point out any area you would need revision on, and help you for free.
Free Title-page
A title page preceeds all your paper content. Here, you put all your personal information and this we give out for free.
Free Bibliography
Without a reference/bibliography page, any academic paper is incomplete and doesnt qualify for grading. We also offer this for free.
Originality & Security
At Homework Sharks, we take confidentiality seriously and all your personal information is stored safely and do not share it with third parties for any reasons whatsoever. Our work is original and we send plagiarism reports alongside every paper.
24/7 Customer Support
Our agents are online 24/7. Feel free to contact us through email or talk to our live agents.
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
We work around the clock to see best customer experience.
Pricing
Our prces are pocket friendly and you can do partial payments. When that is not enough, we have a free enquiry service.
Communication
Admission help & Client-Writer Contact
When you need to elaborate something further to your writer, we provide that button.
Deadlines
Paper Submission
We take deadlines seriously and our papers are submitted ahead of time. We are happy to assist you in case of any adjustments needed.
Reviews
Customer Feedback
Your feedback, good or bad is of great concern to us and we take it very seriously. We are, therefore, constantly adjusting our policies to ensure best customer/writer experience.