Question: Problem 5 : Create [ 2 0 points ] You work for a company that receives timestamped orders from several stations. Because different stations are
Problem : Create points
You work for a company that receives timestamped orders from several stations. Because different
stations are located at different distances, not all orders are received in the order in which they
were placed at the stations. For example, you might receive an order with an earlier timestamp
after one, or several, later orders have already been received. In this problem we will focus only on
the timestamps of the orders.
To simplify this problem, assume that each timestamp is an integer, all timestamps are differ
ent, and for any two timestamps, the earlier timestamp corresponds to a smaller integer than the
later timestamp. The timestamps in the stream are not in their correct order, but you have some
failsafe procedure that ensures that every timestamp integer in the stream is at most posi
tions away from its correctly sorted position. You want to fulfill the order in the orders in which
they were places. Your job is to output a stream of correctly sorted timestamps.
Design an algorithm that outputs the timestamps in the correct order. You can only use a con
stant amount of storage, ie the memory used should be independent of the total number of
timestamps processed otherwise an increased volume of orders would be unsustainable Make
sure to do the following things: Describe your algorithm, Give an argument regarding the
correctness of your algorithm ie why does your algorithm give a correctly sorted stream and
State and briefly justify the time complexity of your algorithm considering n as total number of
timestamps, and every timestamp is at most k in this case k but give your solution in terms
of k positions away from its correctly sorted position. Be sure to double check that you have
done all three things.Problem : Create points
You work for a company that receives timestamped orders from several stations. Because different
stations are located at different distances, not all orders are received in the order in which they
were placed at the stations. For example, you might receive an order with an earlier timestamp
after one, or several, later orders have already been received. In this problem we will focus only on
the timestamps of the orders.
To simplify this problem, assume that each timestamp is an integer, all timestamps are differ
ent, and for any two timestamps, the earlier timestamp corresponds to a smaller integer than the
later timestamp. The timestamps in the stream are not in their correct order, but you have some
failsafe procedure that ensures that every timestamp integer in the stream is at most posi
tions away from its correctly sorted position. You want to fulfill the order in the orders in which
they were places. Your job is to output a stream of correctly sorted timestamps.
Design an algorithm that outputs the timestamps in the correct order. You can only use a con
stant amount of storage, ie the memory used should be independent of the total number of
timestamps processed otherwise an increased volume of orders would be unsustainable Make
sure to do the following things: Describe your algorithm, Give an argument regarding the
correctness of your algorithm ie why does your algorithm give a correctly sorted stream and
State and briefly justify the time complexity of your algorithm considering as total number of
timestamps, and every timestamp is at most in this case but give your solution in terms
of positions away from its correctly sorted position. Be sure to double check that you have
done all three things.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
