Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello, would someone please help me with this question on sorting alogrithm problem with effective memory use, Thank you so much!!!! The input to this

Hello, would someone please help me with this question on sorting alogrithm problem with effective memory use, Thank you so much!!!!

image text in transcribed

image text in transcribed

The input to this problem consists of a sequence of 7-digit phone numbers written as simple integers (e.g. 5551202 represents the phone number 555-1202). The sequence is provided via an itr Iterator Integer . Note that you do not get an array containing these phone numbers and you cannot go through the iterator more than once. The sequence is potentially too large to fit in the memory limit you are allowed for this problem so be careful about what data structures (if any) you use. No phone number appears in the input more than once. Ensure that your solution works for all 7-digit phone numbers for numbers 100-0000, 100-0001, ..., 999-9998, 999-9999. Write Java-like code for a method that prints out the phone numbers (as integers) in the list in ascending order. Your solution must not use more than 2MB (where MB =106 bytes) of memory. You should count the amount of memory used by variables and arrays you create and can assume that the memory used by Java to manage them is negligible. Do not circumvent this by using external memory such as files, hard drive, network, etc. In your code you may only declare variables and arrays of these unsigned data types: bit ( 1 bit), byte ( 8 bits), short ( 16 bits), int ( 32 bits), long ( 64 bits) Because some of these are not real Java data types, your code does not have to compile. We will accept any correct answers as long as it is "Java-like". You may not use any other data structures. // YOUR CODE HERE public static void sortPhoneNumbers(Iterator> itr) \{ \} Count how much memory your code uses. List each variable or array in its own bullet point and tell us how much memory they use then just add them all up at the end and make sure it is obvious it is below the 2MB limit. No explanation needed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions