NeoAlgo icon indicating copy to clipboard operation
NeoAlgo copied to clipboard

Graph Problem:-Minimum Number of Swaps Required to Sort an Array

Open DrSehgal7 opened this issue 6 years ago • 10 comments

🚀 Feature

You are given an unordered array consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates. You are allowed to swap any two elements. You need to find the minimum number of swaps required to sort the array in ascending order.

Have you read the Contributing Guidelines on Pull Requests?

YES

Motivation

As it has not beed added in any issue in hakin-codes.

Pitch

Very Common Algorithm. It is Useful in Solving Many Graph related Problems.

DrSehgal7 avatar Aug 16 '20 10:08 DrSehgal7

@Kajol-Kumari @SKAUL05 @Abhijit2505 @plazzy99 @siddharth25pandey Can you please add the relevant labels to it and assign the issue to me. Thank you!

DrSehgal7 avatar Aug 16 '20 10:08 DrSehgal7

Hey @DrSehgal7 can you please mention the language you are going to do it?

Kajol-Kumari avatar Aug 17 '20 06:08 Kajol-Kumari

@Kajol-Kumari Would like to work on C++ and C both

DrSehgal7 avatar Aug 17 '20 07:08 DrSehgal7

I would like to work on this in Python

AkM-2018 avatar Aug 17 '20 07:08 AkM-2018

I would like to work on this in Java.

ritvij14 avatar Aug 17 '20 18:08 ritvij14

@ritvij14 go with java

vatsalkesarwani12 avatar Aug 18 '20 05:08 vatsalkesarwani12

@DrSehgal7 I had a doubt about this algorithm. Is the array consisting of any set of consecutive integers that are arranged unordered? Or is it like the first N consecutive integers from 1 to N?

ritvij14 avatar Aug 18 '20 19:08 ritvij14

@ritvij14 For example N= 50 so you will have an array of 50 elements and all of them will be from 1 to 50 without duplicates. For eg:- N=10 array[]={3 7 6 9 1 8 10 4 2 5} ans=9

I hope your doubt is clear now!

DrSehgal7 avatar Aug 18 '20 20:08 DrSehgal7

@DrSehgal7 yes it's clear now, thanks for the clarification. :D

ritvij14 avatar Aug 18 '20 20:08 ritvij14

Please reopen this issue once you add more information and updates here. If this is not the case and you need some help, feel free to seek help from our Telegram or ping one of the reviewers. Thank you for your contributions!

github-actions[bot] avatar Oct 18 '20 00:10 github-actions[bot]