=Paper= {{Paper |id=Vol-3010/PAPER_06 |storemode=property |title=Sliding Window Sort for Multidimension Array |pdfUrl=https://ceur-ws.org/Vol-3010/PAPER_06.pdf |volume=Vol-3010 |authors=Krishanu Majumder,Dipankar Das }} ==Sliding Window Sort for Multidimension Array== https://ceur-ws.org/Vol-3010/PAPER_06.pdf
Sliding Window Sort for Multidimension Array
Krishanu Majumder a, Dipankar Das a
  a
      Dept of Computer Science & Engineering, Jadavpur University, Kolkata, India

                 Abstract
                 Sorting numbers in an array are one of the most basic problems that we learn to solve and have
                 always proved useful. Though there are many algorithms for sorting in 1 dimensional array of
                 numbers, there are not many algorithms which can be applied to 2 dimension or higher
                 dimension arrays. In this paper, we will discuss a new algorithm for sorting 2-dimensional
                 array and will see how it can be modified to sort n-dimensional array.

                 Keywords 1
                 Sorting, Multidimensional array

1. Introduction
   Sorting have been one of the oldest solved problems but conventionally limited to 1 dimensional
array of numbers. But with growing complexities with matrices, tensors and multidimensional arrays,
we might face situations where we need to sort a collection of numbers which are in form of a n-
dimensional matrix. We normally do it by converting the multidimensional array into 1 dimensional
array, apply the known sorting algorithms to it and restore the array into its previous form. But the
question comes can we do it without transforming the array into a 1-dimensional array with a time
complexity which will not be worse than the worst time complexities of the known algorithms? Yes,
we definitely can. We will see how we can sort a 2D matrix and then we will extend the algorithm to
multidimensional array.




Figure 1: Starting state on the left and target state on the right.

2. Related Works
   Sorting is one of the very first problem that we learn. There are many sorting algorithms proposed
and some of the widely accepted ones include bubble sort, selection sort, insertion sort, quick sort [1],
merge sort [2] to name a few. These algorithms are fit for linear collection of data but mostly not for
complex data structures like tensors or multidimensional arrays. Among this, bubble sort, insertion sort
and selection sort have the overall time complexity of O(n2). Quick sort has an average case time
complexity as Ɵ(nlogn) but have a worst time complexity of O(n2). On the other hand, merge sort has
both average and worst time complexity of O(nlogn) but it uses extra space with worst case space
complexity as O(n). Many authors like Oyelami et. al. [3,4] have proposed modifications over the
existing algorithms by still they are confined to one-dimension arrays only.

Algorithms, Computing and Mathematics Conference, August 19 – 20, 2021, Chennai, India.
EMAIL: majumder.krishanu95@gmail.com (Krishanu Majumder)
ORCID: 0000-0002-6537-0403 (Krishanu Majumder)
            © 2021 Copyright for this paper by its authors.
            Use permitted under Creative Commons License Attribution 4.0 International (CC BY 4.0).
            CEUR Workshop Proceedings (CEUR-WS.org)


                                                                                  81
    But very few works have been done in the field of multidimensional arrays. One of the interesting
works have been presented by Sandeep Sen et. al. [5,6]. They proposed a new algorithm called shear
sort which sorts a 2-D array by alternatingly sorting the rows and columns. The authors used it to sort
networks. Other works on 2-dimensional sorting was done in the field of VLSI and networks by
Thompson and Kung [7], Nissimi and Sahni [8], Hans-Warner et. al. [11] which mainly uses bitonic
sort [9] or odd even merge sort [10] using parallel computing. Douglas [12] tried to implement bubble
sort in 2-dimension array. Hanan Samet [13,14] discussed the applications of multidimensional sorting
in real world like in graphics, game theory, etc.

3. Algorithm
   We take a window of 2x2 for a 2-dimensional matrix of size m x n. So, the window will have the
elements (i,j), (i,j+1), (i+1,j) and (i+1,j+1) for all 0<=i