-
Is this the simplest (and most surprising) sorting algorithm ever?
Authors:
Stanley P. Y. Fung
Abstract:
We present an extremely simple sorting algorithm. It may look like it is obviously wrong, but we prove that it is in fact correct. We compare it with other simple sorting algorithms, and analyse some of its curious properties.
We present an extremely simple sorting algorithm. It may look like it is obviously wrong, but we prove that it is in fact correct. We compare it with other simple sorting algorithms, and analyse some of its curious properties.
△ Less
Submitted 3 October, 2021;
originally announced October 2021.
-
Optimal Online Two-way Trading with Bounded Number of Transactions
Authors:
Stanley P. Y. Fung
Abstract:
We consider a two-way trading problem, where investors buy and sell a stock whose price moves within a certain range. Naturally they want to maximize their profit. Investors can perform up to $k$ trades, where each trade must involve the full amount. We give optimal algorithms for three different models which differ in the knowledge of how the price fluctuates. In the first model, there are global…
▽ More
We consider a two-way trading problem, where investors buy and sell a stock whose price moves within a certain range. Naturally they want to maximize their profit. Investors can perform up to $k$ trades, where each trade must involve the full amount. We give optimal algorithms for three different models which differ in the knowledge of how the price fluctuates. In the first model, there are global minimum and maximum bounds $m$ and $M$. We first show an optimal lower bound of $\varphi$ (where $\varphi=M/m$) on the competitive ratio for one trade, which is the bound achieved by trivial algorithms. Perhaps surprisingly, when we consider more than one trade, we can give a better algorithm that loses only a factor of $\varphi^{2/3}$ (rather than $\varphi$) per additional trade. Specifically, for $k$ trades the algorithm has competitive ratio $\varphi^{(2k+1)/3}$. Furthermore we show that this ratio is the best possible by giving a matching lower bound. In the second model, $m$ and $M$ are not known in advance, and just $\varphi$ is known. We show that this only costs us an extra factor of $\varphi^{1/3}$, i.e., both upper and lower bounds become $\varphi^{(2k+2)/3}$. Finally, we consider the bounded daily return model where instead of a global limit, the fluctuation from one day to the next is bounded, and again we give optimal algorithms, and interestingly one of them resembles common trading strategies that involve stop loss limits.
△ Less
Submitted 16 June, 2017;
originally announced June 2017.
-
Improved Randomized Online Scheduling of Intervals and Jobs
Authors:
Stanley P. Y. Fung,
Chung Keung Poon,
Feifeng Zheng
Abstract:
We study the online preemptive scheduling of intervals and jobs (with restarts). Each interval or job has an arrival time, a deadline, a length and a weight. The objective is to maximize the total weight of completed intervals or jobs. While the deterministic case for intervals was settled a long time ago, the randomized case remains open. In this paper we first give a 2-competitive randomized alg…
▽ More
We study the online preemptive scheduling of intervals and jobs (with restarts). Each interval or job has an arrival time, a deadline, a length and a weight. The objective is to maximize the total weight of completed intervals or jobs. While the deterministic case for intervals was settled a long time ago, the randomized case remains open. In this paper we first give a 2-competitive randomized algorithm for the case of equal length intervals. The algorithm is barely random in the sense that it randomly chooses between two deterministic algorithms at the beginning and then sticks with it thereafter. Then we extend the algorithm to cover several other cases of interval scheduling including monotone instances, C-benevolent instances and D-benevolent instances, giving the same competitive ratio. These algorithms are surprisingly simple but have the best competitive ratio against all previous (fully or barely) randomized algorithms. Next we extend the idea to give a 3-competitive algorithm for equal length jobs. Finally, we prove a lower bound of 2 on the competitive ratio of all barely random algorithms that choose between two deterministic algorithms for scheduling equal length intervals (and hence jobs).
△ Less
Submitted 13 April, 2012;
originally announced April 2012.
-
Bounded Delay Packet Scheduling in a Bounded Buffer
Authors:
Stanley P. Y. Fung
Abstract:
We study the problem of buffer management in QoS-enabled network switches in the bounded delay model where each packet is associated with a weight and a deadline. We consider the more realistic situation where the network switch has a finite buffer size. A 9.82-competitive algorithm is known for the case of multiple buffers (Azar and Levy, SWAT'06). Recently, for the case of a single buffer, a 3…
▽ More
We study the problem of buffer management in QoS-enabled network switches in the bounded delay model where each packet is associated with a weight and a deadline. We consider the more realistic situation where the network switch has a finite buffer size. A 9.82-competitive algorithm is known for the case of multiple buffers (Azar and Levy, SWAT'06). Recently, for the case of a single buffer, a 3-competitive deterministic algorithm and a 2.618-competitive randomized algorithm was known (Li, INFOCOM'09). In this paper we give a simple deterministic 2-competitive algorithm for the case of a single buffer.
△ Less
Submitted 16 July, 2009;
originally announced July 2009.