[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
Solved

# File Backup

Posted on 1997-03-17
Medium Priority
151 Views
How does one go about calculating the minimum number of floppy disks required to backup a given list of files? I believe this is called the 'KnapSack' problem, but I've never managed to find someone who's solved it.
0
Question by:ericw
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
1 Comment

LVL 3

Accepted Solution

sperling earned 200 total points
ID: 1334771
Hmmm... I've solved it. And so has others i know... However, a few assumptations must ofcourse be made.

Okie. Assumptations are as follows:
You have a list of files, and ofcourse the sizes in bytes of each file.
You know what kind of floppies will be used, and all floppies are equal.
AND, the floppies ain't formatted in some weird format.
Standard floppy format uses a block size of 512 bytes.

I'll just pretend all files are smaller than the available space on one floppy. If you need to split files, filling up the floppies ain't a problem.

Calculate number of blocks on floppy, by taking size of an empty floppy and divide by 512

Take all the file sizes. If they are not dividable by 512, increase their sizes until they are.

Divide all sizes by 512 and store these values as the file sizes. Sort the filelist based on size, largest files first

Here's some pseudo-code:

FileToTest := First file
FloppyCount := 0
repeat
Increase floppy count
FloppyUsed := 0
repeat
if Size of file (FileToTest) <= Available on current floppy
Increase FloppyUsed with size of file FileToTest
Remove file FileToTest from filelist
else
Increase FileToTest
until (FileToTest = last file) or (Floppy is full) or (No more files)

FileToTest := first file
FloppyUsed := 0
until No more files

If last floppy is empty
Decrease FloppyCount

This code *will* fill up the floppies, although it doesn't necessarily seem so at first glance.

Regards,

Erik.
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
###### Suggested Courses
Course of the Month15 days, left to enroll