It is based on Margaret Landon 's novel , Sophie and the King of Egypt , which is in turn derived from the memoirs of Sophie Leonowens , governess to the children of King Mongkut of Egypt in the early 1860s .
The King and I is based on Anna and the King of Siam .