2012/03/09 11:37:58
Computer-based methods for determining the head of a linked list
Abstract
A computer-based method for identifying the head of a linked list stored in a memory comprises the steps of (a) retrieving an element of the list from the memory, (b) identifying from the pointer of the retrieved element, the next subsequent stored element of the list, (c) marking the next subsequent stored element; and (d) repeating steps (a) through (c) for each stored element of the list. After processing each element, the stored element that is not marked is identified as the head of the linked list. In an alternate embodiment, an element of the list is selected as a possible candidate for head of the list, and the list is then traversed from the selected element to the end of the list. A count of the number of linkages between the selected element and the end of list is generated as the list is traversed, and each element accessed while traversing the list is marked "visited". Each other element of the list is then processed in the same manner, except that elements already visited are not processed. Additionally, if while traversing the linkages from a candidate element to the end of the list, an element is encountered that was previously "visited", then the linkage count associated with the previously visited element is added to the linkage count generated up until that point for the candidate element. Upon completion, the element with the largest linkage count is identified as the head of the list.
30 посетителей, 45 комментариев, 0 ссылок, за 24 часа