I write, therefore I amWith this variation on a famous statement by the philosopher Descartes, I would like to express that writing about what happens in my life is important to me. | |||
Friday, February 3, 2012Little snowThis morning around 11:20, it started to snow, but only very light. It continued for some hours, and also in the evening there was some more, but the total was just a few milimeter of snow. In the rest of the country there was a lot snow leading to second worse evening traffic jam (and fourth worse overall) on record and problems with the trains.Improved sorting algorithmI found, what I think is, an improvement on the algorith that I talked about yesterday. The idea is that once you have concluded that the element at c needs to placed before the element at i, you move it to the front and compare it with every element that you encounter. If there is an element that needs to be placed before it, you keep it in front and also move it with you. The elements b to e are the elements that are moved to the front. With every step moving it to the front, you try to move the next element before it through the group, while comparing it. If it moves through, it is okay, otherwise it is made part of the group that of elements that moves to the front.
for (int c = 1; c < n; c++)
for (int i = 0; i < c; i++)
if (before(a[c], a[i]))
{
int e = c+1;
for (int b = c; i < b; b--)
{
int j;
for (j = b; j < e; j++)
if (before(a[j-1], a[j]))
break;
else
swap(a[j-1], a[j]);
if (j == e)
e--;
}
break;
}
However, this algorith is not stable. I think that the next algorith is:
for (int c = 1; c < n; c++)
for (int i = 0; i < c; i++)
if (before(a[c], a[i]))
{
int e = c+1;
for (int b = c; i < b; b--)
{
bool pass = true;
for (int j = b; j < e; j++)
if (before(a[b-1], a[j]))
{
pass = false;
break;
}
if (pass)
{
for (int j = b; j < e; j++)
swap(a[j-1], a[j]);
e--;
}
}
break;
}
Thursday, February 2, 2012Sorting with partial relationIn the afternoon, I improved a sorting algorithm written by a colleague for sorting an array with a partial relation, which might be non-transitive. The traditional definition of partial order (see Wikipedia) includes the transitivity requirement. The algorithm here works on a smaller-than relation (which is also not reflexive) and sorts an array of unique values such that afterwards there are no two elements placed in the wrong order with respect to the smaller-than relation. The non-transitive partial relation is comparable to acyclic directed graphs with labels. The number of such relations on n elements is given by the integer sequence A003024: "Number of acyclic digraphs (or DAGs) with n labeled nodes." I think that the algorithm is also stable, meaning that it doesn't unnecessary changes the position of elements. The following C++ fragment gives the algorithm, where "a" represents the array to be sorted and "n" the number of elements. The function "before" returns true when the first argument should appear before the second and the function "swap" swaps the contents of the two arguments.
for (int c = 1; c < n; c++)
for (int i = 0; i < c; i++)
if (before(a[c], a[i]))
{
for(; i < c; c--)
swap(a[c-1], a[c]);
break;
}
I haven't tested the above implementation yet. The central idea of the algorithm is that all elements from 0 to (but not including) c are correctly sorted. I am not sure whether this is the optimal algorithm. LinkMonday, January 30, 2012Drainage for natural wellsLast week they started to install drainage for a natural well along Hendrik Ter Kuilestraat in Enschede. I reported about some natural wells on Tuesday, April 7, 2009. I made mentioning of three natural wells. In the mean time two of these wells seem to have dried-up. I guess that the three wells have a common source, and that the newest well (which occured after reconstruction of the road crossing with Kanaalstraat) has caused the two older wells to dry-up. In the past years the new well (picture) has been causing a lot of problems and several times have seen some ground work taking place along this area, possibly trying to find a 'leak'. I guess that they finally have realized that it is a natural well and that installing drainage is the only solution.Sunday, January 29, 2012Thin layer of snowThis evening, a thin layer of snow fell on the ground. Now more snow has been predicted and the prediction says temperatures are going to be low the coming week.Saturday, January 28, 2012Book saleAt bookshop De Slegte they were selling all the books that were on sale for just one Euro each. At 12:47, I bought the following books (in random order):
Of the last book, they had still five in store. Only two had a drawing that I liked. I think I will cut one of the books (I already bought one three weeks ago) in loose sheets and give away the other. Of course, I keep the drawings. The seller told me that they never sold one of the books for the price of € 20. I also bought the book Intimiteit by Willy Pasini (ISBN:9027428220) for € 6.95. Thursday, January 26, 2012LinkMonday, January 23, 2012Chinese New YearToday is the first day of the year of the dragon according to the Chinese calendar. The spring festival has begun.Leo VromanToday, at 16:46, I bought the book Misschien tot morgen (See you tomorrow, maybe), diary 2003-2006 by Leo Vroman (ISBN:9789021485348) for € 2,50 from bookshop De Slegte.Sunday, January 22, 2012Where is Jelle?This evening, just like every other evening, I was reading to Andy from one of the reports of the weekend and holiday care that he attends. Today, I was reading from Monday, July 12, 2010. When I was about half way the report, Andy suddenly shouted: "Where is Jelle" (Jelle is a Dutch boy name). I had not read about Jelle being at the care, but it often happens that children come and go. Knowing Andy's excellent autobiographical memory, I expected that the name of Jelle would come up. And yes, indeed it did, suddenly he was mentioned in the evening. I asked Andy when Jelle had arrived. He immediately answered: 12 o'clock (at noon time) with a big smile. It would not surprise me if he is absolutely right. Now it must be the case that I have read this report before in the time in between, but it still it is a remarkable feat for any person to remember this kind of detail. Andy (now 14) is always very keen on noticing who is present and not. He is the one who immediately notices when someone is missing. During the breaks at school he will often walk up to the teacher of another class to ask where this and this child is, if the child is not present. I wonder if these kind of remarkable (almost Savant like) skills are common among people with Kabuki Syndrome.
|
IntroductionDiariesFebruary 2012 January 2012 December 2011 November 2011 2012 2011 Alzheimer's Disease Trip to China 2010 -- contact -- FamilyFransLi-Xia Annabel Andy Honeymoon Faase Family tree Friends Others Pictures
| ||
| |||