Hi I came across a question in the Algorithms 4th Edition by Robert Sedgewick.
Dequeue sort. Explain how you would sort a deck of cards, with the res
A very simple solution is here using java. Just keep shifting the top element by comparing and keep track of the number of sorted elements. On every iteration, it will give us one smallest element based on the position. We will do this based on n and k values. For n values, we will keep shifting based on bigger elements and for k values, we will just keep shifting based on smaller values and eventually, the solution will come. You can try this.