Listing 20.7, DirectorySize.java, gives a recursive method for finding a directory size. Rewrite this method without using
Question:
Listing 20.7, DirectorySize.java, gives a recursive method for finding a directory size. Rewrite this method without using recursion. Your program should use a queue to store the subdirectories under a directory. The algorithm can be described as follows:
Transcribed Image Text:
long getSize (File directory) { long size = 0; add directory to the queue; while (queue is not empty) { Remove an item from the queue into t; if (t is a file) size += t.1ength(); else add all the files and subdirectories under t into the queue; return size;
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 75% (4 reviews)
Program Plan Create class DirectorySize It contains two method which are mainString args and getSize...View the full answer
Answered By
ANDREW KIPRUTO
Academic Writing Expert
I have over 7 years of research and application experience. I am trained and licensed to provide expertise in IT information, computer sciences related topics and other units like chemistry, Business, law, biology, biochemistry, and genetics. I'm a network and IT admin with +8 years of experience in all kind of environments.
I can help you in the following areas:
Networking
- Ethernet, Wireless Airmax and 802.11, fiber networks on GPON/GEPON and WDM
- Protocols and IP Services: VLANs, LACP, ACLs, VPNs, OSPF, BGP, RADIUS, PPPoE, DNS, Proxies, SNMP
- Vendors: MikroTik, Ubiquiti, Cisco, Juniper, HP, Dell, DrayTek, SMC, Zyxel, Furukawa Electric, and many more
- Monitoring Systems: PRTG, Zabbix, Whatsup Gold, TheDude, RRDtoo
Always available for new projects! Contact me for any inquiries
4.30+
1+ Reviews
10+ Question Solved
Related Book For
Introduction to Java Programming, Comprehensive Version
ISBN: 978-0133761313
10th Edition
Authors: Y. Daniel Liang
Question Posted:
Students also viewed these Computer science questions
-
Rewrite Listing 18.7, DirectorySize.java, without using recursion. Listing 1 import java.io.File; 2 import java.util.Scanner; 3 4 public class DirectorySize { public static void main(String[] args) {...
-
Rewrite Programming Exercise 18.28 using a stack instead of a queue. DirectorySize.java, without using recursion. ? 1 import java.io.File; 2 import java.util.Scanner; 3 4 public class DirectorySize {...
-
Listing 7.9, Calculator.java, is a simple commandline calculator. Note that the program terminates if any operand is nonnumeric. Write a program with an exception handler that deals with nonnumeric...
-
Mary is 30 years old and married to Mark, age 36. Mark passed away on January 30, 2021. Mark was unemployed and had no income in 2021 due to his illness. Marys seven-year-old daughter, Jenny, lived...
-
In any metric space the following three definitions of compactness are equivalent: 1. Every sequence has a convergent subsequence. 2. Every open cover has a finite sub cover. 3. Every collection of...
-
A sample of 125 is drawn from a population with a proportion equal to 0.65. Determine the probability of observing a. 80 or fewer successes. b. 82 or fewer successes. c. 75 or more successes....
-
How might these conflicts be resolved? LO5
-
In the following debate, take the position of an investor who wants to evaluate the liquidity of a company. Team Debate: Team 1: Argue for including inventory, prepaids, and deferrals in working...
-
On December 30, Year 4, Fort, Inc., issued 1,000 of its 8%, 10-year, $1,000 face value bonds with detachable stock warrants at par. Each bond carried a detachable warrant for one share of Forts...
-
1. By changing the way his group talks about IT investments, CIO Tim Schaefer is trying to change the way the rest of the company sees IT. Why do you think this is necessary? What would be the...
-
When you pick four cards from a deck of 52 cards for the 24-point game introduced in Programming Exercise 20.13, the four cards may not have a 24-point solution. What is the number of all possible...
-
This exercise is a variation of the 24-point card game described in Programming Exercise 20.13. Write a program to check whether there is a 24-point solution for the four specified numbers. The...
-
A researcher is interested in the effects of exercise on mental health and he proposes the following study: Use stratified random sampling to ensure representative proportions of 18-30, 31-40 and 41-...
-
1. The KYM company wants to invest $ 523,000 pesos in the bank that guarantees a simple interest rate of 3.32% quarterly. If the company is considering the 8-month investment. What amount will you...
-
3. (5 points) The uncertainty principle limits our ability to determine simultaneously the position and momentum of a particle. (a) Why were classical physicists unaware of the limitations that this...
-
CASE STUDY Patient Name Valarie Ramirez Attending Paul F. Buckwalter, MD PATIENT INFORMATION DOB 08/04/1986 Allergies MAN 00-AA-006 Penicillin Other Information Past HX: AB x1 Valarie Ramirez arrives...
-
Petesy Corporation is preparing its Master Budget for 2019. Budget information is as follows: SalesProduction CostOperating Expenses 20191 st Quarter P280,000P192,000P64,000 2 nd Quarter 320,000...
-
A steady flow of 20 m3/s of moist air at TDB = 35iC, TWB = 25iC, 100 kPa (state 1) is dehumidified by first cooling it and condensing out moisture (state 2), then reheating it to 20iC and 50% R.H....
-
For a statistics class project, Jonathan and Crystal held an ice-cream eating contest. They randomly selected 29 males and 35 females from their large high school to participate. Each student was...
-
Draw and label the E and Z isomers for each of the following compounds: 1. CH3CH2CH==CHCH3 2. 3. 4. CH,CH2C CHCH2CH Cl CH3CH2CH2CH2 CH CH2CCCH2CI CHCH3 CH3 HOCH CH CCC CH O-CH C(CH
-
In Figure 9.9, why is the destination hardware address of the frame from A to B a broadcast address? Figure 9.9 System A System B N2 N1 L1 L2 (Not known by A) Ox0001 Ox04 Ox0800 06 Ox0001 ARP request...
-
When we send a letter using the services provided by the post office, do we use an end-to-end address? Does the post office necessarily use an end-to-end address to deliver the mail? Explain.
-
In Figure 9.9, how does system A know what the link-layer address of system B is when it receives the ARP reply? Figure 9.9 System A System B N2 N1 L1 L2 (Not known by A) Ox0001 Ox04 Ox0800 06 Ox0001...
-
Abc. Co. has one employee who earns $500 per week and is paid every Monday for the previous week worked. December 31st is a Wednesday. Your employee works Monday-Friday. a. Record the required...
-
Your company has purchased equipment worth $40,000 and would like to compare the impact of straight-line depreciation versus accelerated depreciation (double declining method). The equipment has a...
-
You have $22,000 to invest. You want to purchase shares of Alaska Air at $43.76, Best Buy at $52.62, and Ford Motor at $9.16. How many shares of each company should you purchase so that your...
Study smarter with the SolutionInn App