Consider GCET’s central library where the librarian Mario is required to sort the books before closing each day. The library has long shelves, and the books are numbered through 1 to N, the librarian wishes to arrange the books so that they appear in the sequence 1,2, …, N. He intends to do this by a sequence of moves. In each move Mario can pick up any book and insert it at a different place. Let he has 5 books and they are initially arranged in the order: 1 4 5 3 2 Mario will rearrange this in ascending order by first moving book 2 to the beginning of the shelf to get : 1 2 4 5 3 Then moving book 3 to position 3, he gets 1 2 3 4 5 You are required to write a program for Mario that determines the minimum number of moves that are necessary to sort the bookshelf. please solve with Flowchart and description
Consider GCET’s central library where the librarian Mario is required to sort the
books before closing each day. The library has long shelves, and the books are
numbered through 1 to N, the librarian wishes to arrange the books so that they appear
in the sequence 1,2, …, N.
He intends to do this by a sequence of moves. In each move Mario can pick up any
book and insert it at a different place. Let he has 5 books and they are initially arranged
in the order: 1 4 5 3 2
Mario will rearrange this in ascending order by first moving book 2 to the beginning
of the shelf to get : 1 2 4 5 3
Then moving book 3 to position 3, he gets 1 2 3 4 5
You are required to write a program for Mario that determines the minimum number
of moves that are necessary to sort the bookshelf.
please solve with Flowchart and description
Step by step
Solved in 2 steps with 1 images