codezonediitj / pydatastructs

A python package for data structures and algorithms
https://pydatastructs.readthedocs.io/en/stable/
Other
201 stars 267 forks source link

Previous/Next Permutation #404

Closed czgdp1807 closed 2 years ago

czgdp1807 commented 2 years ago

Description of the problem

We should add previous and next permutation algorithm to pydatastructs. A good place to add it will be miscellaneous_data_structures.algorithm.

Example of the problem

Following is the interface of the above algorithm in my mind,

previous_perm(sequence) -> Output will be a sequence
next_perm(sequence) -> Output will be a sequence
next_perm([1, 2, 3]) -> [1, 3, 2]

References/Other comments

[1] http://www.cplusplus.com/reference/algorithm/next_permutation/ [2] http://www.cplusplus.com/reference/algorithm/next_permutation/

pratikgl commented 2 years ago

I want to work on this.