125,731 research outputs found

    2-stack pushall sortable permutations

    Full text link
    In the 60's, Knuth introduced stack-sorting and serial compositions of stacks. In particular, one significant question arise out of the work of Knuth: how to decide efficiently if a given permutation is sortable with 2 stacks in series? Whether this problem is polynomial or NP-complete is still unanswered yet. In this article we introduce 2-stack pushall permutations which form a subclass of 2-stack sortable permutations and show that these two classes are closely related. Moreover, we give an optimal O(n^2) algorithm to decide if a given permutation of size n is 2-stack pushall sortable and describe all its sortings. This result is a step to the solve the general 2-stack sorting problem in polynomial time.Comment: 41 page

    Distributed stabilizing data structures

    Full text link
    Distributed algorithms aim to achieve better performance than sequential algorithms in terms of time complexity (or asymptotic time complexity) while keeping or lowering the memory requirement (space complexity) in a node. (In sequential algorithms, the memory requirement is the memory requirement of the algorithm itself.); Self-stabilizing distributed algorithms aim to achieve a comparable performance to non-stabilizing distributed algorithms when transient faults or arbitrary initialization cause the system to enter a state where a non-stabilizing algorithm cannot continue to properly perform its task; Transient faults can affect an existing data structure and alter its data content. As a result, the data structure may lose its properties, and the operations defined over the data structure will have unpredictable and undesirable results, making the data structure unusable; We present several self or snap-stabilizing algorithms for particular data structures; We propose an optimal self-stabilizing distributed algorithm for simultaneously activating non-adjacent processes on an oriented chain (Algorithm SSDS ). We use Algorithm SSDS to accomplish two tasks: local mutual exclusion and line sorting. We propose two uniform, self-stabilizing, deterministic protocols on oriented chains: a time and space optimal solution to the local mutual exclusion problem (Algorithm LMEC ), and a space and (asymptotic) time optimal solution to the distributed sorting problem (Algorithm SORTc ); We extend Algorithm SSDS to an asynchronous oriented ring with a distinguished node with some minor modifications, and we obtain general self-stabilization for simultaneously activated non-adjacent processes in an oriented ring with a distinguished process (Algorithm SSDSR ). We use Algorithm SSDSR to accomplish two tasks: local resource allocation and ring sorting. We propose two uniform, self-stabilizing, deterministic protocols on oriented rings: a time and space optimal solution to the local resource allocation problem (Algorithm LRAR ), and a space and (asymptotic) time optimal solution to the distributed sorting problem (Algorithm SORTr ); We extend Algorithm SSDS to an asynchronous rooted tree, and we obtain general self-stabilization for simultaneously activated non-adjacent processes in a rooted tree (Algorithm SSDST ). We then give two applications of Algorithm SSDST : a time and space optimal solution to the local mutual exclusion problem (Algorithm LMET ) and a space and (asymptotically) time optimal solution to the min heap problem (Algorithm HEAP ); In proving the time complexity of sorting, we introduce the notion of pseudo-time, similar to logical time introduced by Lamport; We present the first snap-stabilizing distributed binary search tree (BST) algorithm. The proposed algorithm uses a heap algorithm (Algorithm Heap) as a preprocessing step. This is also the first snap-stabilizing distributed solution to the heap problem

    Visualization and Animation of Sorting Algorithms

    Get PDF
    Sorting is one of the most important and challenging topics in the study of data structures and algorithm analysis. The time complexity of most sorting algorithms is in the range between 0(n^2 ) and O(n log n). Commonly used sorting strategies include: 1) sorting by exchanging adjacent elements, 2) sorting by using a binary tree structure, and 3) sorting by using a divide and conquer strategy. The typical examples of above sorting strategies are insertion sort, heapsort, and quicksort, respectively. The speed of a sorting process is heavily depended on the algorithm employed. For educational purposes, it is important for students to understand the underlying step by step processes of sorting algorithms. Visualization and animation of sorting algorithms may provide a useful aid to achieve this goal. The advantage of visualization is that it provides a direct sensation of a complicated abstract concept. This study visualized and animated the processes of insertion sort, two variants of heapsort, and quicksort, by displaying every single comparison, movement and exchange of each algorithm in detail. The study also executed and animated the four algorithms in the same time at the same screen for a same set of data to provide a real time comparison of different sorting algorithms. Finally, the study also compared and analyzed the performances of different algorithms for large data sets, based on the running time calculated from the counts of comparisons, swaps and moves that each algorithm took

    Constant Queue Route on a Mesh

    Get PDF
    Packet routing is an important problem in parallel computation since a single step of inter-processor communication can be thought of as a packet routing task. In this paper we present an optimal algorithm for packet routing on a mesh-connected computer. Two important criteria for judging a routing algorithm will be 1) its run time, i.e., the number of parallel steps it takes for the last packet to reach its destination, and 2) its queue size, i.e., the maximum number of packets that any node will have to store at any time during routing. We present a 2n - 2 step routing algorithm for an n x n mesh that requires a queue size of only 58. The previous best known result is a routing algorithm with the same time bound but with a queue size of 672. The time bound of 2n - 2 is optimal. A queue size of 672 is rather large for practical use. We believe that the queue size of our algorithm is practical. The improvement in the queue size is possible due to (from among other things) a new 3s + o(s) sorting algorithm for an s x s mesh

    Sorting suffixes of two-pattern strings

    Get PDF
    Recently, several authors presented linear recursive algorithms for sorting suffixes of a string. All these algorithms employ a similar three-step approach, based on an initial division of the suffixes of x into two sets: in step 1 sort the first set using recursive reduction of the problem, in step 2 determine the order of the suffixes in the second set based on the order of the suffixes in the first set, and in step 3 merge the two sets together. To optimize such an algorithm either for space or time, it may not be sufficient to optimize one of the three steps, since in doing so, one might increase the resources required for the others to an unacceptable extent. Franek, Lu, and Smyth introduced two-pattern strings as a generalization of Sturmian strings. Like Sturmian strings, two-pattern strings are generated by iterated morphisms, but they exhibit a much richer structure. In this paper we show that the suffixes of two-pattern strings can be sorted in linear time using a variant of the three step approach outlined above. It turns out that, given the order of the suffixes in a two-pattern string, one can almost directly list in linear time all the suffixes of its expansion under a two-pattern morphism
    corecore