Skip to content
#

Algorithm

Algorithms are detailed sets of guidelines created for a computer program to complete tasks efficiently and thoroughly.

Here are 7,783 public repositories matching this topic...

javascript-algorithms
wnesensohn
wnesensohn commented May 23, 2016

Selection Sort, for example, makes the algorithm look extremely (impossibly) good at first glance - O(n) - because it's not showing the majority of the steps.

Instead of

    for (var j = i + 1; j < D.length; j++) {
        if (D[j] < D[minJ]) {
            tracer._select(j);
            minJ = j;
            tracer._deselect(j);
        }
    }

it has to be more like

    for (var j
leetcode
azl397985856
azl397985856 commented Feb 5, 2020

ๅ‡ๅฆ‚ๆœ‰ไธ€ๆŽ’ๆˆฟๅญ๏ผŒๅ…ฑ n ไธช๏ผŒๆฏไธชๆˆฟๅญๅฏไปฅ่ขซ็ฒ‰ๅˆทๆˆ็บข่‰ฒใ€่“่‰ฒๆˆ–่€…็ปฟ่‰ฒ่ฟ™ไธ‰็ง้ขœ่‰ฒไธญ็š„ไธ€็ง๏ผŒไฝ ้œ€่ฆ็ฒ‰ๅˆทๆ‰€ๆœ‰็š„ๆˆฟๅญๅนถไธ”ไฝฟๅ…ถ็›ธ้‚ป็š„ไธคไธชๆˆฟๅญ้ขœ่‰ฒไธ่ƒฝ็›ธๅŒใ€‚

ๅฝ“็„ถ๏ผŒๅ› ไธบๅธ‚ๅœบไธŠไธๅŒ้ขœ่‰ฒๆฒนๆผ†็š„ไปทๆ ผไธๅŒ๏ผŒๆ‰€ไปฅๆˆฟๅญ็ฒ‰ๅˆทๆˆไธๅŒ้ขœ่‰ฒ็š„่Šฑ่ดนๆˆๆœฌไนŸๆ˜ฏไธๅŒ็š„ใ€‚ๆฏไธชๆˆฟๅญ็ฒ‰ๅˆทๆˆไธๅŒ้ขœ่‰ฒ็š„่Šฑ่ดนๆ˜ฏไปฅไธ€ไธช n x 3 ็š„็Ÿฉ้˜ตๆฅ่กจ็คบ็š„ใ€‚

ไพ‹ๅฆ‚๏ผŒcosts[0][0] ่กจ็คบ็ฌฌ 0 ๅทๆˆฟๅญ็ฒ‰ๅˆทๆˆ็บข่‰ฒ็š„ๆˆๆœฌ่Šฑ่ดน๏ผ›costs[1][2] ่กจ็คบ็ฌฌ 1 ๅทๆˆฟๅญ็ฒ‰ๅˆทๆˆ็ปฟ่‰ฒ็š„่Šฑ่ดน๏ผŒไปฅๆญค็ฑปๆŽจใ€‚่ฏทไฝ ่ฎก็ฎ—ๅ‡บ็ฒ‰ๅˆทๅฎŒๆ‰€ๆœ‰ๆˆฟๅญๆœ€ๅฐ‘็š„่Šฑ่ดนๆˆๆœฌใ€‚

ๆณจๆ„๏ผš

ๆ‰€ๆœ‰่Šฑ่ดนๅ‡ไธบๆญฃๆ•ดๆ•ฐใ€‚

็คบไพ‹๏ผš

่พ“ๅ…ฅ: [[17,2,17],[16,16,5],[14,3,19]]
่พ“ๅ‡บ: 10
่งฃ้‡Š: ๅฐ† 0 ๅทๆˆฟๅญ็ฒ‰ๅˆทๆˆ่“่‰ฒ๏ผŒ1 ๅทๆˆฟๅญ็ฒ‰ๅˆทๆˆ็ปฟ่‰ฒ๏ผŒ2 ๅทๆˆฟๅญ็ฒ‰ๅˆทๆˆ่“่‰ฒใ€‚
  ๆœ€ๅฐ‘่Šฑ่ดน: 2 + 5 + 3 = 10ใ€‚

้ข˜็›ฎๅœฐๅ€๏ผš ht

๐Ÿ“š C/C++ ๆŠ€ๆœฏ้ข่ฏ•ๅŸบ็ก€็Ÿฅ่ฏ†ๆ€ป็ป“๏ผŒๅŒ…ๆ‹ฌ่ฏญ่จ€ใ€็จ‹ๅบๅบ“ใ€ๆ•ฐๆฎ็ป“ๆž„ใ€็ฎ—ๆณ•ใ€็ณป็ปŸใ€็ฝ‘็ปœใ€้“พๆŽฅ่ฃ…่ฝฝๅบ“็ญ‰็Ÿฅ่ฏ†ๅŠ้ข่ฏ•็ป้ชŒใ€ๆ‹›่˜ใ€ๅ†…ๆŽจ็ญ‰ไฟกๆฏใ€‚

  • Updated Feb 23, 2020
  • C++
BitYog
BitYog commented Nov 30, 2017

Hey @mgechev,
I noticed that you have a README.md file in src/sorting, which has the Big O complexity for all algorithms. It also has the "When to use" column, which is blank. Basecs already has many algorithms' explanations, and can be used to fill in this.column. The explanations are valid for most languages and are concise.

Also, a README.md for all src/* folders would be helpful. (I would

Wikipedia
Wikipedia
You canโ€™t perform that action at this time.