“This is the 10th day of my participation in the Gwen Challenge in November. Check out the details: The Last Gwen Challenge in 2021.”

Hello everyone, I am quick-frozen fish 🐟, a front end of water system 💦, like colorful whistle 💐, continuous sand sculpture 🌲, I am a good brother of the next door Cold grass Whale, I just started to write an article. If you like my article, you can follow ➕ to like it, inject energy into me, and grow with me

Preface 🌧 ️

Algorithms are unfamiliar and familiar to the front-end people, and often we don’t value them as much as the back-end engineers do. But in fact, algorithms have an unshakable position for every programmer.

Because the development process is to convert the actual problem into the computer can recognize the instructions, that is, “data structure” said, “design the data structure, in the application of algorithms on the line”.

The quality of writing instructions will directly affect the performance of the program, and instructions are composed of data structure and algorithm, so the design of data structure and algorithm basically determines the quality of the final program.

In addition, when reading the source code, the lack of understanding of algorithms and data structures makes it difficult to understand why the author wrote the way he did.

In today’s environment, algorithms have become an indispensable skill for front-end engineers. If we want to move beyond being application engineers writing business code, we need to understand algorithms and data structures.

Of course, learning is also focused, as the front end we do not need to fully grasp the algorithm like back-end development, some of the more partial, not practical type and solution method, as long as a little understanding.

Select the sorting idea 🦀

  • Find the smallest value in the array, select it and place it first.
  • Then find the second-smallest value, select it and place it in the second place.
  • And so on, perform the N-1 round.

Select sort animation 🌵

Source 🔥

Array.prototype.selectionSort=function(){
    for(let j=0; j<this.length-1; j++){let minIndex=j
        for(leti=j; i<this.length; i++){if(this[minIndex]>this[i]){
                minIndex=i
            }
        }
        const temp=this[j]
        this[j]=this[minIndex]
        this[minIndex]=temp
    }

}

const array=[5.4.3.2.1]

array.selectionSort()

console.log(array);

Copy the code

Time complexity :O(n^2)

Conclusion 🌞

So fish fish LeetCode algorithm “LeetCode” JavaScript- select sort ⚡️ is over, algorithm this thing has no shortcut, can only write more practice, more summary, the purpose of the article is actually very simple, is to urge myself to complete algorithm practice and summary and output, dishes are not important, but love 🔥, I hope everyone can like my essay, and I also hope to know more like-minded friends through the article. If you also like to toss, welcome to add my friend, sand sculpture together, together progress.

Making 🤖 : sudongyu

Personal blog 👨💻: Frozen fish blog

Vx 👦 : sudongyuer

Write in the last

Guys, if you like my words, give 🐟🐟 a thumbs up 👍 or follow ➕ to support me the most.

Add me on wechat: Sudongyuer, invite you into the group and learning the front together, become a better engineer ~ (group of qr code here – > front to go to bed early, qr code has expired, see the links to the boiling point in the comments, I will put the latest qr code in the comments section, of course, can also add me WeChat I pull you into the group, after all, I also am interesting front end, I also not bad 🌟 ~