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: 66% (3 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 firm is being organized that requires an initial investment of $20 million. You have $200,000 and will buy 0.01 of the common stock if the firm is 100 percent financed with common stock. The use of...
-
Reconsider Problem 56. Determine which oven should be purchased based on an incremental annual worth analysis. Data from problem 56 Octavia Bakery is planning to purchase one of two ovens. The...
-
Doug's Custom Construction Company is considering three new projects, each requiring an equipment investment of $22,000. Each project will last for 3 years and produce the following net annual cash...
-
You are a co-op student at Modus Biosystems and have been asked to research whether there are ways to save money on their legal liability insurance. Modus currently pays $75,000 a year for a policy...
-
Demello & Associates records adjusting entries on an annual basis. The company has the following information available on accruals that must be recorded for the year ended December 31, 2017: 1....
-
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...
-
Make a change of variables or use an algebra step before evaluating the following integrals. dx 1 x + 2x + 5
-
ABC Ltd have purchased a new piece of equipment for their business to increase their operating capacity. The amount that was paid to the supplier is $100,000. Delivery fees to get the equipment to...
-
What evidence did Broadwind management provide to the auditors to support that a decline in sales was temporary? . What evidence would have been sufficient for GT to conclude that the decline in...
-
The band is breaking up and Rob, Sue, Tim, and Vito each want the tour bus. Using the method of sealed bids, Rob bids $3600, Sue bids $4700, Tim bids $3700, and Vito bids $8000 for the bus. Since...
-
) Portfolio (Narrative) Students are required to create a children's story centered around a narrative from the visual, aural, haptic and kinaesthetic perspective of a child. The narrative should be...
-
Learn with an If T=[[-4,-7]] and U=[[1,1],[-1,-4]], what is TU? If the matrix exists, select its size before entering you select undefined.
-
Bennett Basketball sells a variety of basketballs and accessories. Information follows for Bennett Basketball's purchases and sales during February and March for Up-Snap, one of its top brands of...
-
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...
-
How can bash shell scripting improve resource utilization and process management in Unix systems?
-
A solid sphere that is uniformly positively charged produces an electric field. Assume no other objects are around. What is the magnitude of the electric field a distance r from the center of the...
-
Why is potential difference important in x - ray production?
Study smarter with the SolutionInn App