Rajan Kumar

rajan

Founder & Programmer at HackersFriend Updated Jan. 23, 2019, 12:04 a.m. ⋅ 70 views

Shuffle elements of an Array most efficient way , Fisher Yates shuffle algorithm


Problem:

You are given an array of N elements, shuffle elements of this array in such a way that, occurance of any element at any position is equally likely.

Given:

A rand() function that returns any value between 0.0 to 1.0 randomly and a floor() function that gives significant integer from any given float value.

 

Soltuion: 

We'll use Fisher Yates Algorithm to solve this problem. you can watch explanation in video.

 



arrow_upward Upvote

comment Comment

arrow_downward downvote



Go back to feed

HackersFriend Updates





View more


Events


Nov. 28, 2018, 5:30 p.m.

Python from zero to hero

place Delhi

View details


Aug. 13, 2018, 5:30 p.m.

Python from zero to hero

place Bangalore ( HackersFriend office BTM Layout)

View details