Friday, May 6, 2011

Some problems on sequences and linked lists

sequences:
1) In a sequence if integers every integer except one appears even number of times. Determine exception's value using O(1) memory and one lookup through the sequence.
2) In a sequence of integers more than half of elements are the same. Dermine it's value using O(1) memory and one lookup through the sequence.

lists:
1) There is a single-linked list with unknown number of elements. Determine if the last element of the list links to NULL or to some element in the list using O(1) memory.
2) Show how to implement a doubly-linked list using only sizeof(void*) bytes for linking information. a) only one iterator is allowed, b) many independent iterators are allowed. Assume no elements are added to/deleted from the list when iterators start working.

No comments:

Post a Comment