Write a program which takes as input an array of digits encoding a non-negative decimal integer D and updates the array to represent the integer D + 1. For example, if the input is (1,2,9) then you should update the array to (1,3,0). Your algorithm should work even if it is implemented in language that … Continue reading Increment an Arbitrary-Precise Integer
Category: Array
The Dutch National Flag Problem
The Dutch national flag problem (DNF) is a programming problem proposed by Edsger Dijkstra. The flag of the Netherlands consists of three colors: red, white and blue. Given balls of these three colors arranged randomly in a line (the actual number of balls does not matter), the task is to arrange them such that all balls of the same … Continue reading The Dutch National Flag Problem