17.11 Word Distance: You have a large text file containing words. Given any two words, find the shortest distance (in terms of number of words) between them in the file. If the operation wi" be repeated many t imes for the same file (but different pairs of words), can you optimize your solution?
Complexity: O(n^3) preprocessing - for every combinational relationship between words i and j, find the minimum distance within their occurances, O(1) postprocessing - through matrix lookup. O(n^2) space from matrix
The Idea: First read in the file contents and build a dictionary of each word and where they occur. Build a matrix that provides lookup by id strings (aka 2d hash table), then for every combinational relationship between words compute the minimum distance. Computing the minimum distance requires a linear traversal between both lists within the assumption that the occurances for each word are sorted. Simply increment the list that will ensure a closer absolute difference. Then flip the matrix to provide the user-friendly lookup (word1,word2) == (word2,word1).
Alice Mabel Bacon (February 26, 1858 – May 1, 1918) was an American writer, women's educator and a foreign advisor to the Japanese government in Meiji period Japan.
Early life
Alice Mabel Bacon was the youngest of three daughters and two sons of Leonard Bacon, pastor of the Center Church in New Haven, Connecticut, and professor in the Yale Divinity School, and his second wife, Catherine Elizabeth Terry Bacon.[1] In 1872, when Alice was fourteen, Japanese envoy Mori Arinori selected her father's home as a residence for Japanese women being sent overseas for education by the Meiji government, as part of the Iwakura Mission.[2] Alice received twelve-year-old Yamakawa Sutematsu as her house-guest. The two girls were of similar age, and soon formed a close bond. For ten years the two girls were like sisters and enhanced each other's interests in their different cultures.[2][3]
Education and career
Alice subsequently graduated from high school, but was forced to give up hopes of attending university due to economic circumstances. Nevertheless, she was able to pass examinations for a Bachelor of Arts from Harvard University in 1881, and received a post in 1883 as a teacher at the Hampton Institute.
In 1888, Alice received an invitation to come to Japan from Yamakawa Sutematsu and Tsuda Umeko to serve as a teacher of the English language at the Gakushuin Women's School for Japanese girls from aristocratic families. She returned to Hampton Normal School after a year. Hearing that one of her students wanted to become a nurse but was refused entrance into training schools because of her race Ms. Bacon sought to established a hospital at the Institute. With the help of General Samuel C. Armstrong, Hampton's principal, enough funds were raised to construct the Dixie Hospital. The hospital which opened in May 1891 provided nursing education as well as medical care for the surrounding community.
In April 1900, she was invited back to Japan to help establish the Joshi (Women's) Eigaku (English) Juku (Preparatory School), which was the forerunner of Tsuda College, staying until April 1902. During most of this period, she assisted Tsuda Umeko on a voluntary basis, refusing monetary compensation except for her housing.
Alice remained single all of her life, although she did adopt two Japanese girls as her daughters. One of these girls, Hitotsuyanagi Makiko subsequently married William Merrell Vories.
Based on her experiences in Japan, Bacon published three books and many essays, and eventually came to be known as a specialist of Japanese culture and women.