Imagine a program that compresses files by 80 percent and stores them on storage media. Before the compressed file is stored, it must be divided into blocks of 512 bytes each. Develop an algorithm for this program that first reads the number of blocks available on the storage media. Then, in a loop, read the uncompressed size of a file and determine whether the compressed file will fit in the space left on the storage media. If so, the program should compress and save the file. It continues until it encounters a file that will exceed the available space on the media. For example, suppose the media can hold 1000 blocks. A file of size 1100 bytes will compress to size 880 and require 2 blocks. The available space is now 998 blocks. A file of size 20,000 bytes will compress to size 16,000 and
What will be an ideal response?
1. Get the number of free blocks and assign it to the variable free
2. Let haveSpace be true
3. While haveSpace
3.1. Get size of the file in bytes
3.2. Compute the compressed size of the file in bytes
3.3. Determine the number of blocks needed for the file
3.4. If the number of blocks needed is less than the free space
3.4.1. Reduce the number of free blocks
3.5. Else
3.5.1. Let haveSpace be false
3.5.2. guess is 1 to max
You might also like to view...
Estimate average network delay for a five-node unweighted string topology network, as shown in Figure 4.5 of this solution manual, for the following scenario: a node transmits 100 data packets each of size 100Kb, the packet transmission rate is set to be 1Mbps, and the speed of packet transmission is assumed to be unity.
What allows you to manage attached files in forms and reports?
A) Attachment control B) Attached File control C) Hyperlink control D) Attachment subform/subreport
What is not critical when you are first designing a database?
A) What tables you will need B) What fields you will need C) What type of data will be stored in each field D) What the field names will be
What Cisco IOS command is used to create a VLAN and enter into VLAN configuration mode?
A) interface vlan vlan B) vlan vlan C) vlan name D) primary vlan vlan