Preview

Java

Good Essays
Open Document
Open Document
490 Words
Grammar
Grammar
Plagiarism
Plagiarism
Writing
Writing
Score
Score
Java
Write a Java program to demonstrate using bitmaps and bitwise operators to sort and remove duplicates from a file of random phone numbers. Do not confuse the term bitmap used for compressing data into smaller spaces with the bitmap that has come to mean a graphic image.
You will use this file of 4 million random phone numbers with possible repeats in args[0]. In addition, will be given an output filename provided inargs[1] into which you will write the sorted list of phone numbers without duplicates.
Each phone number begins with the digit 2 or greater so phone numbers are 2000000 through 9999999. There are no area codes or country code prefixes to deal with. The file looks something like:
9827019
5655875
2593305
8586163
6115967
9128969
9998369
8551496
...
Here are some declarations to get you started:
Scanner inFile = new Scanner(new FileReader(args[0]));
PrintWriter outFile = new PrintWriter(args[1]); byte[] bitmap = new byte[1000000];
You will use a bitmap as an array of 1,000,000 bytes (that is, the type byte). Each bit in the array of one million bytes will represent one phone number. The bit will be turned on if and only if the number was read from the file. Those bits that remain off will indicate the number was never found in the file.
You will want to review Bitwise Operators.
Using this bitmap association will guarantee no repeats in the resultant file and as a side effect automatically sorts the data since you will process the bitmap sequentially from beginning to end inspecting every bit and writing the phone number represented by that bit to the output file if the bit is turned on.
Process all values before writing to the output file.
Your output file should have all the found numbers with no duplicates in ascending, sorted order.
As a guide d2.dat is provided above and is 32,000,000 bytes. Your result file should be 25,195,720 bytes on Unix or 28,345,185 in Windows/DOS. Values other than this indicate an error in processing and you may want to

You May Also Find These Documents Helpful

  • Satisfactory Essays

    You want to maintain a list of your contacts. You retain the following information, lastname, firstname, address, city, state, zip code and phone numbers.…

    • 298 Words
    • 2 Pages
    Satisfactory Essays
  • Good Essays

    Array Structure Paper

    • 833 Words
    • 4 Pages

    Once again Berry’s Bug Blasters are requesting an update to the previous program that was designed to help them to better serve their customers. The company has requested a way to display the name and phone number of their clients so that they can keep a record of what clients have called. The best way in the opinion to accomplish this is to build an array into the program. This will allow those in charge of the company record to record who has called and then to display the names of the clients and their number in a chart so that it can be recalled at a later date as needed.…

    • 833 Words
    • 4 Pages
    Good Essays
  • Satisfactory Essays

    It 250 Homework 4

    • 769 Words
    • 4 Pages

    A. Redirect the standard output from a sort command into a file named phone_list. Assume that the input file is named numbers.…

    • 769 Words
    • 4 Pages
    Satisfactory Essays
  • Powerful Essays

    Telephone systems have many different features this allows us to handle and manage calls in a professional manner.…

    • 3590 Words
    • 17 Pages
    Powerful Essays
  • Good Essays

    Which of the following can be used to keep a record of incoming telephone calls so that no message is overlooked? Telephone log…

    • 750 Words
    • 3 Pages
    Good Essays
  • Good Essays

    The past couple of decades have seen a tremendous growth in technology. Phones, phone calls, and how we make them, are no exception - a lot has changed since the days of the PBX operator. Today a lot of phone calls being made are being made over the internet –vs- over traditional phone lines. Just like everything else on the internet, there are protocols in place when it comes to making and receiving phone calls.…

    • 698 Words
    • 2 Pages
    Good Essays
  • Good Essays

    U2 Assessment

    • 3300 Words
    • 12 Pages

    The keypad has pre-set dial numbers, each button or key sends call to a specific number. They are used to make regular calls easier with one touch only.…

    • 3300 Words
    • 12 Pages
    Good Essays
  • Satisfactory Essays

    8 Service Codes

    • 419 Words
    • 2 Pages

    5. There are 8,000,000 phone numbers available in each area code of TV land. 800*1*1*1*10*10*10*10=8,000,000. I multiplied 8 for the service codes by 10 for the middle number since it opened up, then by 10 for the digits which equaled 800. Then multiplied that by 1*1*1 representing the “555”, then multiplied that by 10*10*10*10 representing the last 4 digits of the phone…

    • 419 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    The New I3 Phone System

    • 3844 Words
    • 16 Pages

    One frequently asked question in business today that is least answered is, as stated by David Chaudron, PhD (2003), “What can we do to make our business flourish, survive and grow?” With the rapid changes in technology and the rise in the globalization of markets, we must have a game plan in place for adjusting to these changes. It has become increasingly difficult to predict what is going to happen, and there are thousands of obstacles and opportunities along the way. To add to the confusion, there are thousands of products, solutions and methods for dealing with these changes. With many brands, sizes and varieties it is very difficult to choose what is best for your organization. Add to that, what if it is the wrong choice? Some probably would opt not to make any decision at all for fear of making the wrong decision. Although, it may not be easy to change due to a certain comfort level with the current organizational culture which has grown over a period of time. The fact is that sometimes organizational culture needs to change to support the organization 's success and progress.…

    • 3844 Words
    • 16 Pages
    Powerful Essays
  • Good Essays

    Java

    • 5076 Words
    • 21 Pages

    Explanation: B) Programs are classified as software to differentiate them from the mechanisms of the computer (hardware). Storage and the processor are two forms of hardware while input is the information that the program processes.…

    • 5076 Words
    • 21 Pages
    Good Essays
  • Satisfactory Essays

    Outline

    • 265 Words
    • 2 Pages

    Borth, David. (2012) Encyclopedia Britannica Facts Matter: Telephone. Retrieved on September 12, 2012, from http://www.britannica.com/EBchecked/topic/585993/telephone…

    • 265 Words
    • 2 Pages
    Satisfactory Essays
  • Satisfactory Essays

    4) Design an algorithm that does the following: Opens the number_list.dat file that was created by the algorithm created in question 3, reads all of the numbers from the file.…

    • 544 Words
    • 4 Pages
    Satisfactory Essays
  • Satisfactory Essays

    One of these features is telecommunications. This enables users to have conversations, in a business, this would be used to communicate within the business, and also make external calls to clients/customers.…

    • 262 Words
    • 2 Pages
    Satisfactory Essays
  • Powerful Essays

    Our phone saves the phone number and information, stores it into a database so we don’t have to remember everyone’s numbers. We can then just search for the name of the contact we want and it will appear.Airports depend on databases constantly, for example – once we have bought our flight tickets from a newsagents or online, our purchase is entered into a database that contains all the people who are going on holiday. When your boarding pass is scanned at the airport desks, the computer goes into the database which finds your specific passenger details so that they know that you have paid for your flights and are going to the correct destination. Without this, airport staff would have to look through the entire list of passengers for every flight just to find our correct booking which would waste a lot of time also it would be much more stressful. A database is also used in an airport to display the different flights on a departures board so passengers can…

    • 866 Words
    • 4 Pages
    Powerful Essays
  • Good Essays

    The Last Ride Together

    • 666 Words
    • 3 Pages

    Write a program to input a start limit S (S>0) and the last limit L (L>0). Print all the prime triplets between S and L (both inclusive), if S<=L otherwise your program should ask to re-enter the values of S and L again with a suitable error message.…

    • 666 Words
    • 3 Pages
    Good Essays