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...
-
On January 1, 202X, Lemming Corporation sold $480,000 of 6%, 10-year bonds at 96. Interest is to be paid on June 30 and December 31. The straightline method of amortizing the discount is used....
-
The Thermo-Bond Manufacturing Company maintains its fixed-asset records on its computer. The fixed-asset master file includes the following data items: Required Refer to Table 9-7, which describes...
-
Smith Clinic, Inc., is preparing its statement of cash flows (indirect method) for the year ended March 31, 2012. Consider the following items in preparing the companys statement of cash flows....
-
The file SPSSExam.sav contains data regarding students' performance on an SPSS exam
-
Jimmy owns a garden in which he has planted N trees in a row. After a few years, the trees have grown up and now they have different heights. Jimmy pays much attention to the aesthetics of his...
-
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...
-
Repeat Problem 10. 8 using a straight-line depreciation method over 7 years. Compare the results with those obtained in Problem 10.8. Which depreciation method would you use? Data from problem 10.8...
-
5 . Calculate the tension required by the deltoid muscle to support a 3 kg ball held in the hand as illustrated below. Mass of arm = 3 . 5 kg Centre of gravity of arm ( Xarm ) = 3 5 cm from shoulder...
-
Navigate to Connect, watch the "Management Hits Rough Waters" video, and answer the questions provided. Which managerial challenges do you feel were the biggest obstacle(s) in the meeting portrayed...
-
1 The access point is transmitting at 25 mW. The cable and connector between the access point and the antenna creates -2 dB of signal loss. The antenna provides 17 dBi of signal gain. Calculate the...
-
The graph to the right shows the hypothetical cost curves for a representative firm in a perfectly competitive industry. The representative firm's total revenue (TR) for selling the profit-maximizing...
-
a A 3 kg mass is launched at 45 degrees above the horizontal at 5 m/s as part of an engineering contest. To be sure your report stands out, you decide that in addition to the traditional...
-
You own a portfolio that has $3,850 invested in Stock A and $6,100 invested in Stock B. If the expected returns on these stocks are 7.2 percent and 13.1 percent, respectively, what is the expected...
-
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...
-
Just Dew It Corporation reports the following balance sheet information for 2017 and 2018.
-
Profitability Index A project has an initial cost of $60,000, expected net cash inflows of $12,000 per year for 10 years, and a cost of capital of 12%. What is the project's PI? (Hint: Begin by...
-
Let's assume you finance your house through Wells-Fargo Bank. Below, please find the Truth-in-Lending Disclosure (TILD). Calculate Finance Charge, i.e., the dollar amount the credit will cost you at...
Study smarter with the SolutionInn App