[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"categories-en":3,"post:\u002Fpost\u002Falgorithms-and-programming-logic-every-developers-map":37},[4,11,17,24,30],{"id":5,"slug":6,"name":7,"colorHex":8,"iconName":9,"postCount":10},"0e2c1225-f78a-4c20-8c93-998ab9dc93b9","frontend","Frontend","#40484f",null,25,{"id":12,"slug":13,"name":14,"colorHex":15,"iconName":9,"postCount":16},"bc8df70e-b7fb-4d89-a80c-fd458d36d58c","code-development","Code & Development","#8b5cf6",23,{"id":18,"slug":19,"name":20,"colorHex":21,"iconName":22,"postCount":23},"550e8400-e29b-41d4-a716-446655440001","inteligencia-artificial","Artificial Intelligence","#6366f1","brain",14,{"id":25,"slug":26,"name":27,"colorHex":28,"iconName":9,"postCount":29},"ea63b69c-2eb4-4100-81f3-70ce52d33743","tech-news","Tech News","#e50606",4,{"id":31,"slug":32,"name":33,"colorHex":34,"iconName":35,"postCount":36},"550e8400-e29b-41d4-a716-446655440017","how-to-guides","How-To & Guides","#be123c","book-open",2,{"post":38,"related":1437,"translations":1507,"resolved":9},{"id":39,"slug":40,"title":41,"excerpt":42,"image":43,"featured":44,"groupId":45,"publishedAt":46,"readingTime":47,"views":48,"author":49,"category":51,"tags":52,"contentJson":59,"metaTitle":1434,"metaDescription":1435,"updatedAt":1436},"e030fef5-f11d-4dd7-b144-a04918faec49","algorithms-and-programming-logic-every-developers-map","Algorithms and Programming Logic: Every Developer's Map","Learn to solve problems on paper before coding. Understand sequence, selection, repetition, sorting algorithms, and Big O complexity.","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002Ffeatured\u002F1775367487707-featured-9oizul.jpg",false,"af12ac12-a25a-4a7b-afe1-93a2c5512786","2026-06-11T23:51:13.185611+00:00",9,0,{"name":50,"avatar":9},"Genildo Souza",{"slug":13,"name":14,"color":15},[53,56],{"slug":54,"name":55},"javascript","JavaScript",{"slug":57,"name":58},"typescript","TypeScript",{"type":60,"content":61},"doc",[62,75,81,87,97,109,121,127,145,153,159,164,173,179,188,194,202,208,215,221,287,298,306,312,322,329,339,346,356,363,389,397,403,563,587,595,601,613,620,626,658,680,688,694,704,714,721,731,769,792,800,806,814,826,836,844,850,860,867,883,978,982,990,996,1006,1013,1019,1026,1041,1049,1055,1062,1068,1100,1106,1114,1126,1307,1321,1325,1333,1339,1362,1370,1384,1390,1398,1404,1410,1416,1431],{"type":63,"attrs":64,"content":66},"blockquote",{"id":65},"quote_5x17epkf",[67],{"type":68,"attrs":69,"content":71},"paragraph",{"id":70},"p_xywpqrpg",[72],{"text":73,"type":74},"You didn't get stuck because algorithms are hard. You got stuck because no one showed you the problem before handing you the solution. This article fixes that — from the simplest concept all the way to complexity analysis.","text",{"type":68,"attrs":76,"content":78},{"id":77},"p_rzb8c33k",[79],{"text":80,"type":74},"That feeling has a name — and it has a solution. It happens when you try to write code before thinking about the algorithm. It's like trying to build a house without a blueprint: you might even put up some walls, but soon you realize the bathroom ended up in the wrong place.",{"type":68,"attrs":82,"content":84},{"id":83},"p_2fw694za",[85],{"text":86,"type":74},"This article will show you the map every developer needs to master before typing the first line of code.",{"type":88,"attrs":89,"content":91},"heading",{"id":90,"level":36},"h_22owl0qc",[92],{"text":93,"type":74,"marks":94},"What Is an Algorithm, Really?",[95],{"type":96},"bold",{"type":98,"attrs":99,"content":102},"callout",{"id":100,"type":101,"title":9},"call_khokhw1g","tip",[103],{"type":68,"attrs":104,"content":106},{"id":105},"p_dyi73w52",[107],{"text":108,"type":74},"Forget the academic definition for a second.",{"type":68,"attrs":110,"content":112},{"id":111},"p_8vn8kkru",[113,115,119],{"text":114,"type":74},"An algorithm is simply ",{"text":116,"type":74,"marks":117},"a finite, ordered sequence of steps to solve a problem",[118],{"type":96},{"text":120,"type":74},". No ambiguity. No steps that rely on guessing. Each instruction needs to be clear enough for a machine — which doesn't think, it only executes — to follow.",{"type":68,"attrs":122,"content":124},{"id":123},"p_zmjz8qoi",[125],{"text":126,"type":74},"Think about your grandmother's cake recipe. It has ingredients (input data), a preparation order (executable steps), and an expected result (output). If you skip a step or change the order, the cake won't turn out right. With algorithms, the logic is exactly the same.",{"type":98,"attrs":128,"content":131},{"id":129,"type":130,"title":9},"call_84ysh8zi","info",[132],{"type":68,"attrs":133,"content":135},{"id":134},"p_f8elwl8c",[136,140],{"text":137,"type":74,"marks":138},"The big mental shift that separates beginner programmers from solid programmers is: ",[139],{"type":96},{"text":141,"type":74,"marks":142},"first you solve the problem on paper, then you write the code.",[143],{"type":144},"italic",{"type":88,"attrs":146,"content":148},{"id":147,"level":36},"h_o5t1aa8d",[149],{"text":150,"type":74,"marks":151},"The Three Structures That Govern Everything",[152],{"type":96},{"type":68,"attrs":154,"content":156},{"id":155},"p_9z3t0vnn",[157],{"text":158,"type":74},"All programming logic — regardless of language — rests on just three control structures. Yes, just three.",{"type":160,"attrs":161},"image",{"id":162,"alt":9,"src":163,"title":9,"width":9,"height":9},"img_bu5l02s9","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002F1774680165040-gwfhb5.png",{"type":88,"attrs":165,"content":168},{"id":166,"level":167},"h_rktgs818",3,[169],{"text":170,"type":74,"marks":171},"1. Sequence",[172],{"type":96},{"type":68,"attrs":174,"content":176},{"id":175},"p_dvgp7koh",[177],{"text":178,"type":74},"The simplest one. Steps are executed one after another, in the order they appear.",{"type":180,"attrs":181,"content":185},"codeBlock",{"id":182,"language":183,"highlighted":184},"code_91fj9irm","c","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> x \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 10\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> y \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 20\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> soma \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> x \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> y;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">printf\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"Resultado: \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">%d\\n\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, soma);\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[186],{"text":187,"type":74},"int x = 10;\nint y = 20;\nint soma = x + y;\nprintf(\"Resultado: %d\\n\", soma);",{"type":68,"attrs":189,"content":191},{"id":190},"p_ese55cyg",[192],{"text":193,"type":74},"No surprises. The computer reads line by line, from top to bottom.",{"type":88,"attrs":195,"content":197},{"id":196,"level":167},"h_o1xuy3pk",[198],{"text":199,"type":74,"marks":200},"2. Selection (Decision)",[201],{"type":96},{"type":68,"attrs":203,"content":205},{"id":204},"p_4pikegxg",[206],{"text":207,"type":74},"This is where the program gains intelligence. Depending on a condition, it chooses one path or another.",{"type":180,"attrs":209,"content":212},{"id":210,"language":183,"highlighted":211},"code_canmgdly","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (temperatura \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">>\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 38\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">    printf\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"Febre detectada. Consulte um médico.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\\n\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">} \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">else\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">    printf\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"Temperatura normal.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\\n\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[213],{"text":214,"type":74},"if (temperatura > 38) {\n    printf(\"Febre detectada. Consulte um médico.\\n\");\n} else {\n    printf(\"Temperatura normal.\\n\");\n}",{"type":68,"attrs":216,"content":218},{"id":217},"p_2mhw0q8s",[219],{"text":220,"type":74},"There are three main forms of selection:",{"type":222,"attrs":223,"content":226},"bulletList",{"id":224,"tight":225},"ul_9hxpowkc",true,[227,249,268],{"type":228,"attrs":229,"content":231},"listItem",{"id":230},"li_pddv5bwh",[232],{"type":68,"attrs":233,"content":235},{"id":234},"p_wqgh9aly",[236,240,242,247],{"text":237,"type":74,"marks":238},"Simple: ",[239],{"type":96},{"text":241,"type":74},"one or two alternative paths (",{"text":243,"type":74,"marks":244},"if\u002Felse",[245],{"type":246},"code",{"text":248,"type":74},")",{"type":228,"attrs":250,"content":252},{"id":251},"li_bzg9njvz",[253],{"type":68,"attrs":254,"content":256},{"id":255},"p_4q147u0s",[257,261,263,267],{"text":258,"type":74,"marks":259},"Chained: ",[260],{"type":96},{"text":262,"type":74},"choice between multiple paths (",{"text":264,"type":74,"marks":265},"if\u002Felse if\u002Felse",[266],{"type":246},{"text":248,"type":74},{"type":228,"attrs":269,"content":271},{"id":270},"li_m7np1ysc",[272],{"type":68,"attrs":273,"content":275},{"id":274},"p_crkh7jcv",[276,280,282,286],{"text":277,"type":74,"marks":278},"Multiple: ",[279],{"type":96},{"text":281,"type":74},"compare a variable against several fixed values (",{"text":283,"type":74,"marks":284},"switch\u002Fcase",[285],{"type":246},{"text":248,"type":74},{"type":68,"attrs":288,"content":290},{"id":289},"p_t056ejln",[291,293,296],{"text":292,"type":74},"The ",{"text":283,"type":74,"marks":294},[295],{"type":246},{"text":297,"type":74}," is perfect when you have many well-defined options — like the days of the week or the options in a menu.",{"type":88,"attrs":299,"content":301},{"id":300,"level":167},"h_cfxhtewh",[302],{"text":303,"type":74,"marks":304},"3. Repetition (Loops)",[305],{"type":96},{"type":68,"attrs":307,"content":309},{"id":308},"p_czb81z5e",[310],{"text":311,"type":74},"The heart of automation. Running the same block of code multiple times without having to rewrite it.",{"type":68,"attrs":313,"content":315},{"id":314},"p_q33pg9dl",[316,320],{"text":317,"type":74,"marks":318},"Counted repetition",[319],{"type":96},{"text":321,"type":74}," — when you know exactly how many times you will repeat:",{"type":180,"attrs":323,"content":326},{"id":324,"language":183,"highlighted":325},"code_nd954dvk","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">for\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> i \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">; i \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x3C;=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 10\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">; i\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">++\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">    printf\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">%d\\n\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, i);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[327],{"text":328,"type":74},"for (int i = 1; i \u003C= 10; i++) {\n    printf(\"%d\\n\", i);\n}",{"type":68,"attrs":330,"content":332},{"id":331},"p_w9bevefw",[333,337],{"text":334,"type":74,"marks":335},"Repetition with pre-condition",[336],{"type":96},{"text":338,"type":74}," — when you test the condition before entering the loop:",{"type":180,"attrs":340,"content":343},{"id":341,"language":183,"highlighted":342},"code_9cee0kfe","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">while\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (saldo \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">>\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 0\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">    saldo \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">-=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> parcela;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[344],{"text":345,"type":74},"while (saldo > 0) {\n    saldo -= parcela;\n}",{"type":68,"attrs":347,"content":349},{"id":348},"p_dzykhcba",[350,354],{"text":351,"type":74,"marks":352},"Repetition with post-condition",[353],{"type":96},{"text":355,"type":74}," — when the block needs to execute at least once:",{"type":180,"attrs":357,"content":360},{"id":358,"language":183,"highlighted":359},"code_7owyxy4p","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">do\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">    printf\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"Digite um número positivo: \"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">    scanf\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">%d\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x26;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">numero);\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">} \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">while\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (numero \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x3C;=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 0\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">);\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[361],{"text":362,"type":74},"do {\n    printf(\"Digite um número positivo: \");\n    scanf(\"%d\", &numero);\n} while (numero \u003C= 0);",{"type":98,"attrs":364,"content":367},{"id":365,"type":366,"title":9},"call_48wattx5","warning",[368],{"type":68,"attrs":369,"content":371},{"id":370},"p_a3t2evnc",[372,376,378,382,384,387],{"text":373,"type":74,"marks":374},"Golden rule: ",[375],{"type":96},{"text":377,"type":74},"avoid infinite loops interrupted by ",{"text":379,"type":74,"marks":380},"break",[381],{"type":246},{"text":383,"type":74},". If you need a ",{"text":379,"type":74,"marks":385},[386],{"type":246},{"text":388,"type":74}," to exit a loop, the stop condition was probably poorly defined.",{"type":88,"attrs":390,"content":392},{"id":391,"level":36},"h_mi22n1bh",[393],{"text":394,"type":74,"marks":395},"Data Types: The Raw Material of the Program",[396],{"type":96},{"type":68,"attrs":398,"content":400},{"id":399},"p_8na1l11p",[401],{"text":402,"type":74},"Before processing any information, the computer needs to know what type of data it is dealing with. In C, the basic types are:",{"type":404,"attrs":405,"content":407},"table",{"id":406},"tbl_w798fxph",[408,446,476,505,534],{"type":409,"content":410},"tableRow",[411,424,435],{"type":412,"attrs":413,"content":415},"tableHeader",{"align":9,"colspan":414,"rowspan":414,"colwidth":9},1,[416],{"type":68,"attrs":417,"content":419},{"id":418},"p_qaocfln8",[420],{"text":421,"type":74,"marks":422},"Type",[423],{"type":96},{"type":412,"attrs":425,"content":426},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[427],{"type":68,"attrs":428,"content":430},{"id":429},"p_880oiw23",[431],{"text":432,"type":74,"marks":433},"What it stores",[434],{"type":96},{"type":412,"attrs":436,"content":437},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[438],{"type":68,"attrs":439,"content":441},{"id":440},"p_bs44u8x5",[442],{"text":443,"type":74,"marks":444},"Example",[445],{"type":96},{"type":409,"content":447},[448,458,467],{"type":449,"attrs":450,"content":451},"tableCell",{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[452],{"type":68,"attrs":453,"content":455},{"id":454},"p_zjtsa3lm",[456],{"text":457,"type":74},"int",{"type":449,"attrs":459,"content":460},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[461],{"type":68,"attrs":462,"content":464},{"id":463},"p_fi24qrqw",[465],{"text":466,"type":74},"Integer numbers",{"type":449,"attrs":468,"content":469},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[470],{"type":68,"attrs":471,"content":473},{"id":472},"p_92x2p1at",[474],{"text":475,"type":74},"42, -7, 0",{"type":409,"content":477},[478,487,496],{"type":449,"attrs":479,"content":480},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[481],{"type":68,"attrs":482,"content":484},{"id":483},"p_ln4y8zj6",[485],{"text":486,"type":74},"float",{"type":449,"attrs":488,"content":489},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[490],{"type":68,"attrs":491,"content":493},{"id":492},"p_3xj2btnb",[494],{"text":495,"type":74},"Numbers with decimal places",{"type":449,"attrs":497,"content":498},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[499],{"type":68,"attrs":500,"content":502},{"id":501},"p_l61zyi9x",[503],{"text":504,"type":74},"3.14, -0.5",{"type":409,"content":506},[507,516,525],{"type":449,"attrs":508,"content":509},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[510],{"type":68,"attrs":511,"content":513},{"id":512},"p_zuhe5xhj",[514],{"text":515,"type":74},"char",{"type":449,"attrs":517,"content":518},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[519],{"type":68,"attrs":520,"content":522},{"id":521},"p_93gkni0u",[523],{"text":524,"type":74},"A single character",{"type":449,"attrs":526,"content":527},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[528],{"type":68,"attrs":529,"content":531},{"id":530},"p_qcjepyam",[532],{"text":533,"type":74},"'A', 'z'",{"type":409,"content":535},[536,545,554],{"type":449,"attrs":537,"content":538},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[539],{"type":68,"attrs":540,"content":542},{"id":541},"p_lxxw9qpe",[543],{"text":544,"type":74},"char[]",{"type":449,"attrs":546,"content":547},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[548],{"type":68,"attrs":549,"content":551},{"id":550},"p_o59wltfb",[552],{"text":553,"type":74},"Character string (text)",{"type":449,"attrs":555,"content":556},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[557],{"type":68,"attrs":558,"content":560},{"id":559},"p_wad7upgg",[561],{"text":562,"type":74},"\"Hello, world\"",{"type":68,"attrs":564,"content":566},{"id":565},"p_6dprs2en",[567,569,573,575,579,581,585],{"text":568,"type":74},"These data live as ",{"text":570,"type":74,"marks":571},"variables",[572],{"type":96},{"text":574,"type":74}," (values that change during execution) or ",{"text":576,"type":74,"marks":577},"constants",[578],{"type":96},{"text":580,"type":74}," (values that never change). Using constants for fixed values — such as ",{"text":582,"type":74,"marks":583},"PI = 3.14159",[584],{"type":246},{"text":586,"type":74}," — makes the code more readable and safe.",{"type":88,"attrs":588,"content":590},{"id":589,"level":36},"h_dt7xx3lk",[591],{"text":592,"type":74,"marks":593},"Functions: The Secret of Clean Code",[594],{"type":96},{"type":68,"attrs":596,"content":598},{"id":597},"p_1r71go8e",[599],{"text":600,"type":74},"If you catch yourself repeating the same block of code in different places, it's a sign that that snippet deserves to become a function.",{"type":68,"attrs":602,"content":604},{"id":603},"p_rasfl71y",[605,607,611],{"text":606,"type":74},"A function is a ",{"text":608,"type":74,"marks":609},"block of code with a specific purpose",[610],{"type":96},{"text":612,"type":74},". It receives data (parameters), processes it, and returns a result.",{"type":180,"attrs":614,"content":617},{"id":615,"language":183,"highlighted":616},"code_0dn2jm6j","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">float\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> calcularMedia\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">float\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\"> nota1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">float\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\"> nota2\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">float\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\"> nota3\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (nota1 \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> nota2 \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> nota3) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">\u002F\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 3\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[618],{"text":619,"type":74},"float calcularMedia(float nota1, float nota2, float nota3) {\n    return (nota1 + nota2 + nota3) \u002F 3;\n}",{"type":68,"attrs":621,"content":623},{"id":622},"p_rx2m9opc",[624],{"text":625,"type":74},"There are two fundamental types:",{"type":222,"attrs":627,"content":629},{"id":628,"tight":225},"ul_bwjemrws",[630,644],{"type":228,"attrs":631,"content":633},{"id":632},"li_yzs90q8c",[634],{"type":68,"attrs":635,"content":637},{"id":636},"p_4gd4qr4v",[638,642],{"text":639,"type":74,"marks":640},"void: ",[641],{"type":96},{"text":643,"type":74},"the function performs an action and returns nothing (like printing to the screen)",{"type":228,"attrs":645,"content":647},{"id":646},"li_1cfr4hoc",[648],{"type":68,"attrs":649,"content":651},{"id":650},"p_0c47x3hd",[652,656],{"text":653,"type":74,"marks":654},"Typed (int, float...): ",[655],{"type":96},{"text":657,"type":74},"the function performs a calculation and returns a result",{"type":98,"attrs":659,"content":661},{"id":660,"type":101,"title":9},"call_aetjrfze",[662],{"type":68,"attrs":663,"content":665},{"id":664},"p_ymz8fcop",[666,668,672,674,678],{"text":667,"type":74},"Good functions have names that describe exactly what they do. ",{"text":669,"type":74,"marks":670},"calcularMedia()",[671],{"type":246},{"text":673,"type":74}," is much better than ",{"text":675,"type":74,"marks":676},"func1()",[677],{"type":246},{"text":679,"type":74},". Your future self — and your teammates — will thank you.",{"type":88,"attrs":681,"content":683},{"id":682,"level":36},"h_bl44tlm0",[684],{"text":685,"type":74,"marks":686},"Best Practices That Make a Difference",[687],{"type":96},{"type":68,"attrs":689,"content":691},{"id":690},"p_v2ajwecp",[692],{"text":693,"type":74},"Mastering the syntax is the easy part. What separates amateur code from professional code are the habits.",{"type":68,"attrs":695,"content":697},{"id":696},"p_5izy8i56",[698,702],{"text":699,"type":74,"marks":700},"Plan before coding. ",[701],{"type":96},{"text":703,"type":74},"Before opening the editor, define: what data goes in? What comes out? What is the sequence of steps? A sketch on paper is worth more than an hour of trial and error.",{"type":68,"attrs":705,"content":707},{"id":706},"p_cn20ki9k",[708,712],{"text":709,"type":74,"marks":710},"Comment what is not obvious. ",[711],{"type":96},{"text":713,"type":74},"The compiler ignores comments, but your colleagues (and you yourself, six months from now) don't. Document the intent of the code, not just what it does.",{"type":180,"attrs":715,"content":718},{"id":716,"language":183,"highlighted":717},"code_k75tfen4","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">\u002F\u002F Calcula o índice de massa corporal conforme tabela da OMS\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">float\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> imc \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> peso \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">\u002F\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (altura \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">*\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> altura);\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[719],{"text":720,"type":74},"\u002F\u002F Calcula o índice de massa corporal conforme tabela da OMS\nfloat imc = peso \u002F (altura * altura);",{"type":68,"attrs":722,"content":724},{"id":723},"p_h7li91sa",[725,729],{"text":726,"type":74,"marks":727},"Write portable code. ",[728],{"type":96},{"text":730,"type":74},"Avoid operating-system-specific functions when an alternative exists in the ISO C standard. Portable code runs on Windows, Linux, and Unix without modifications.",{"type":68,"attrs":732,"content":734},{"id":733},"p_moc4a9j7",[735,739,741,743,747,748,752,754,758,759,762,763,767],{"text":736,"type":74,"marks":737},"Use meaningful names. ",[738],{"type":96},{"text":740,"type":74},"temperatura",{"text":742,"type":74},", ",{"text":744,"type":74,"marks":745},"contador",[746],{"type":246},{"text":742,"type":74},{"text":749,"type":74,"marks":750},"nomeUsuario",[751],{"type":246},{"text":753,"type":74}," are infinitely better than ",{"text":755,"type":74,"marks":756},"t",[757],{"type":246},{"text":742,"type":74},{"text":183,"type":74,"marks":760},[761],{"type":246},{"text":742,"type":74},{"text":764,"type":74,"marks":765},"n",[766],{"type":246},{"text":768,"type":74},". Clarity is not fussiness — it's respect for whoever reads your code next.",{"type":770,"attrs":771},"speedCards",{"id":772,"cards":773,"title":790,"caption":791},"speed_sy3b1xqc",[774,778,782,786],{"label":775,"value":776,"detail":777},"Plan before coding","Plan first","Sketch inputs, outputs, and steps on paper before opening the editor.",{"label":779,"value":780,"detail":781},"Comment the non-obvious","Document","Document the why for your future self and colleagues.",{"label":783,"value":784,"detail":785},"Write portable code","Portable","Prefer ISO C standard functions over OS-specific ones; runs on Windows, Linux, and Unix without modifications.",{"label":787,"value":788,"detail":789},"Use meaningful names","Clarity","Choose temperatura or nomeUsuario instead of t or n. Clarity is respect for whoever reads your code next.","Best Practices","Four habits that make code easier to read, maintain, and port across systems.",{"type":88,"attrs":793,"content":795},{"id":794,"level":36},"h_8scv13y7",[796],{"text":797,"type":74,"marks":798},"Classic Algorithms Every Programmer Should Know",[799],{"type":96},{"type":68,"attrs":801,"content":803},{"id":802},"p_k3ewq0mc",[804],{"text":805,"type":74},"Theory without practice is decoration. See how the concepts above materialize in real algorithms — the same ones used in databases, search systems, and everyday applications.",{"type":88,"attrs":807,"content":809},{"id":808,"level":167},"h_vxe2jdwn",[810],{"text":811,"type":74,"marks":812},"Linear Search vs. Binary Search: the difference that changes everything",[813],{"type":96},{"type":68,"attrs":815,"content":817},{"id":816},"p_q0eeqjb9",[818,820,824],{"text":819,"type":74},"Imagine you need to find the number ",{"text":821,"type":74,"marks":822},"23",[823],{"type":246},{"text":825,"type":74}," in a list of a thousand numbers.",{"type":68,"attrs":827,"content":829},{"id":828},"p_4vzp1zrp",[830,834],{"text":831,"type":74,"marks":832},"Linear Search",[833],{"type":96},{"text":835,"type":74}," — checks one by one, from start to finish:",{"type":180,"attrs":837,"content":841},{"id":838,"language":839,"highlighted":840},"code_svkr6ece","python","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> busca_linear\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(lista, alvo):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    for\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> i \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">in\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> range\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">len\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(lista)):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">        if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> lista[i] \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> alvo:\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">            return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> i  \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\"># retorna o índice onde encontrou\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> -\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">  # não encontrado\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">numeros \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> [\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">2\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">5\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">8\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">12\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">16\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">23\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">38\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">56\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">72\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">91\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">print\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(busca_linear(numeros, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">23\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">))  \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\"># saída: 5\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[842],{"text":843,"type":74},"def busca_linear(lista, alvo):\n    for i in range(len(lista)):\n        if lista[i] == alvo:\n            return i  # retorna o índice onde encontrou\n    return -1  # não encontrado\n\nnumeros = [2, 5, 8, 12, 16, 23, 38, 56, 72, 91]\nprint(busca_linear(numeros, 23))  # saída: 5",{"type":68,"attrs":845,"content":847},{"id":846},"p_ffhh99kz",[848],{"text":849,"type":74},"It works. But in the worst case, it goes through all elements. In a list of one million? One million comparisons.",{"type":68,"attrs":851,"content":853},{"id":852},"p_nuz2f03z",[854,858],{"text":855,"type":74,"marks":856},"Binary Search",[857],{"type":96},{"text":859,"type":74}," — splits the problem in half at each step. Requires a sorted list:",{"type":180,"attrs":861,"content":864},{"id":862,"language":839,"highlighted":863},"code_3bju472x","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> busca_binaria\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(lista, alvo):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">    inicio \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 0\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">    fim \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> len\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(lista) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    while\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> inicio \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x3C;=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> fim:\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">        meio \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> inicio \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (fim \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> inicio) \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">\u002F\u002F\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 2\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">        if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> lista[meio] \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> alvo:\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">            return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> meio          \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\"># encontrou!\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">        elif\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> lista[meio] \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x3C;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> alvo:\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">            inicio \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> meio \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">    # descarta a metade esquerda\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">        else\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">:\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">            fim \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> meio \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">       # descarta a metade direita\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> -\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">  # não encontrado\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">numeros \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> [\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">2\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">5\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">8\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">12\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">16\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">23\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">38\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">56\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">72\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">91\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">print\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(busca_binaria(numeros, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">23\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">))  \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\"># saída: 5\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[865],{"text":866,"type":74},"def busca_binaria(lista, alvo):\n    inicio = 0\n    fim = len(lista) - 1\n\n    while inicio \u003C= fim:\n        meio = inicio + (fim - inicio) \u002F\u002F 2\n\n        if lista[meio] == alvo:\n            return meio          # encontrou!\n        elif lista[meio] \u003C alvo:\n            inicio = meio + 1    # descarta a metade esquerda\n        else:\n            fim = meio - 1       # descarta a metade direita\n\n    return -1  # não encontrado\n\nnumeros = [2, 5, 8, 12, 16, 23, 38, 56, 72, 91]\nprint(busca_binaria(numeros, 23))  # saída: 5",{"type":98,"attrs":868,"content":870},{"id":869,"type":130,"title":9},"call_ors3ea3s",[871],{"type":68,"attrs":872,"content":874},{"id":873},"p_6seyp1dz",[875,877,881],{"text":876,"type":74},"In a list of one million elements, binary search finds any value in at most ",{"text":878,"type":74,"marks":879},"20 comparisons",[880],{"type":96},{"text":882,"type":74},". It's not magic — it's a logarithm.",{"type":404,"attrs":884,"content":886},{"id":885},"tbl_6devgbft",[887,922,950],{"type":409,"content":888},[889,900,911],{"type":412,"attrs":890,"content":891},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[892],{"type":68,"attrs":893,"content":895},{"id":894},"p_iz06oe8d",[896],{"text":897,"type":74,"marks":898},"Algorithm",[899],{"type":96},{"type":412,"attrs":901,"content":902},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[903],{"type":68,"attrs":904,"content":906},{"id":905},"p_etjzlzwd",[907],{"text":908,"type":74,"marks":909},"Worst case (1 million items)",[910],{"type":96},{"type":412,"attrs":912,"content":913},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[914],{"type":68,"attrs":915,"content":917},{"id":916},"p_dglr8wid",[918],{"text":919,"type":74,"marks":920},"Requires sorting?",[921],{"type":96},{"type":409,"content":923},[924,932,941],{"type":449,"attrs":925,"content":926},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[927],{"type":68,"attrs":928,"content":930},{"id":929},"p_xyxincbw",[931],{"text":831,"type":74},{"type":449,"attrs":933,"content":934},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[935],{"type":68,"attrs":936,"content":938},{"id":937},"p_zab32jm7",[939],{"text":940,"type":74},"1,000,000 comparisons",{"type":449,"attrs":942,"content":943},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[944],{"type":68,"attrs":945,"content":947},{"id":946},"p_z51d4h9i",[948],{"text":949,"type":74},"No",{"type":409,"content":951},[952,960,969],{"type":449,"attrs":953,"content":954},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[955],{"type":68,"attrs":956,"content":958},{"id":957},"p_hj7a3a4w",[959],{"text":855,"type":74},{"type":449,"attrs":961,"content":962},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[963],{"type":68,"attrs":964,"content":966},{"id":965},"p_3cpf6tpr",[967],{"text":968,"type":74},"~20 comparisons",{"type":449,"attrs":970,"content":971},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[972],{"type":68,"attrs":973,"content":975},{"id":974},"p_7a7wjohi",[976],{"text":977,"type":74},"Yes",{"type":160,"attrs":979},{"id":980,"alt":9,"src":981,"title":9,"width":9,"height":9},"img_ztqgvdq7","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002F1774680075576-u4hg26.png",{"type":88,"attrs":983,"content":985},{"id":984,"level":167},"h_jxfueckj",[986],{"text":987,"type":74,"marks":988},"Sorting Algorithms: putting the house in order",[989],{"type":96},{"type":68,"attrs":991,"content":993},{"id":992},"p_40w7ikaa",[994],{"text":995,"type":74},"To use binary search, you need sorted data. And to sort data, you need a sorting algorithm.",{"type":68,"attrs":997,"content":999},{"id":998},"p_jlvinj5d",[1000,1004],{"text":1001,"type":74,"marks":1002},"Bubble Sort",[1003],{"type":96},{"text":1005,"type":74}," — the simplest to understand. It works like bubbles rising to the surface: at each pass, the largest element floats to the end:",{"type":180,"attrs":1007,"content":1010},{"id":1008,"language":839,"highlighted":1009},"code_v0zmfm2p","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> bubble_sort\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(lista):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">    n \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> len\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(lista)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    for\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> i \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">in\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> range\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(n):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">        for\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> j \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">in\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> range\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">0\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, n \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> i \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">            # se o elemento atual é maior que o próximo, troca\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">            if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> lista[j] \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">>\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> lista[j \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]:\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">                lista[j], lista[j \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> lista[j \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">], lista[j]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> lista\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">numeros \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> [\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">64\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">34\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">25\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">12\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">22\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">11\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">90\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">print\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(bubble_sort(numeros))  \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\"># [11, 12, 22, 25, 34, 64, 90]\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[1011],{"text":1012,"type":74},"def bubble_sort(lista):\n    n = len(lista)\n    for i in range(n):\n        for j in range(0, n - i - 1):\n            # se o elemento atual é maior que o próximo, troca\n            if lista[j] > lista[j + 1]:\n                lista[j], lista[j + 1] = lista[j + 1], lista[j]\n    return lista\n\nnumeros = [64, 34, 25, 12, 22, 11, 90]\nprint(bubble_sort(numeros))  # [11, 12, 22, 25, 34, 64, 90]",{"type":68,"attrs":1014,"content":1016},{"id":1015},"p_0v7opah5",[1017],{"text":1018,"type":74},"The same algorithm in C:",{"type":180,"attrs":1020,"content":1023},{"id":1021,"language":183,"highlighted":1022},"code_031ly6zj","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">void\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> bubble_sort\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\"> arr\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">[]\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\"> n\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    for\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> i \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 0\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">; i \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x3C;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> n \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">; i\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">++\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">        for\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">int\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> j \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 0\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">; j \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x3C;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> n \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> i \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">; j\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">++\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">            if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> (\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\">arr\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[j] \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">>\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\"> arr\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[j \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]) {\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">                int\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> temp \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\"> arr\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[j];\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\">                arr\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[j] \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\"> arr\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[j \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">];\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#E36209;--shiki-dark:#FFAB70\">                arr\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[j \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">+\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">] \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> temp;\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">            }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">        }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">    }\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">}\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[1024],{"text":1025,"type":74},"void bubble_sort(int arr[], int n) {\n    for (int i = 0; i \u003C n - 1; i++) {\n        for (int j = 0; j \u003C n - i - 1; j++) {\n            if (arr[j] > arr[j + 1]) {\n                int temp = arr[j];\n                arr[j] = arr[j + 1];\n                arr[j + 1] = temp;\n            }\n        }\n    }\n}",{"type":98,"attrs":1027,"content":1030},{"id":1028,"type":1029,"title":9},"call_42q27g0t","note",[1031],{"type":68,"attrs":1032,"content":1034},{"id":1033},"p_06hrx1o0",[1035,1039],{"text":1036,"type":74,"marks":1037},"Why learn Bubble Sort if it's slow?",[1038],{"type":96},{"text":1040,"type":74}," Because it teaches the fundamental sorting patterns: comparison, swapping, and multiple passes. After understanding Bubble Sort, algorithms like Merge Sort and Quick Sort make immediate sense.",{"type":88,"attrs":1042,"content":1044},{"id":1043,"level":167},"h_gizqhe9d",[1045],{"text":1046,"type":74,"marks":1047},"Recursion: when a function calls itself",[1048],{"type":96},{"type":68,"attrs":1050,"content":1052},{"id":1051},"p_vqjgc6a8",[1053],{"text":1054,"type":74},"A concept that scares beginners but is elegant when you understand it: a function that solves a problem by calling itself with a smaller version of the same problem.",{"type":180,"attrs":1056,"content":1059},{"id":1057,"language":839,"highlighted":1058},"code_zbcw1xkp","\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">def\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> fatorial\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(n):\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">    # caso base: para a recursão\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> n \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 0\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\"> or\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> n \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">==\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">:\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">        return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">    # chamada recursiva com problema menor\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">    return\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> n \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">*\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\"> fatorial(n \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">-\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 1\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">print\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">(fatorial(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">5\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">))  \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\"># 5 × 4 × 3 × 2 × 1 = 120\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>",[1060],{"text":1061,"type":74},"def fatorial(n):\n    # caso base: para a recursão\n    if n == 0 or n == 1:\n        return 1\n    # chamada recursiva com problema menor\n    return n * fatorial(n - 1)\n\nprint(fatorial(5))  # 5 × 4 × 3 × 2 × 1 = 120",{"type":68,"attrs":1063,"content":1065},{"id":1064},"p_s6d11xcx",[1066],{"text":1067,"type":74},"Every recursive function has two mandatory components:",{"type":222,"attrs":1069,"content":1071},{"id":1070,"tight":225},"ul_jk3n38sc",[1072,1086],{"type":228,"attrs":1073,"content":1075},{"id":1074},"li_q89zkr1y",[1076],{"type":68,"attrs":1077,"content":1079},{"id":1078},"p_a0lyle33",[1080,1084],{"text":1081,"type":74,"marks":1082},"Base case: ",[1083],{"type":96},{"text":1085,"type":74},"the stopping condition (without it, infinite recursion)",{"type":228,"attrs":1087,"content":1089},{"id":1088},"li_uxskkgc8",[1090],{"type":68,"attrs":1091,"content":1093},{"id":1092},"p_if6vy7ts",[1094,1098],{"text":1095,"type":74,"marks":1096},"Recursive call: ",[1097],{"type":96},{"text":1099,"type":74},"the problem reduced to a smaller version of itself",{"type":68,"attrs":1101,"content":1103},{"id":1102},"p_k14iml41",[1104],{"text":1105,"type":74},"Recursion is the foundation of powerful algorithms like Merge Sort, tree search, and graph traversal.",{"type":88,"attrs":1107,"content":1109},{"id":1108,"level":167},"h_ebx26nf6",[1110],{"text":1111,"type":74,"marks":1112},"Algorithm Complexity: the cost of what you write",[1113],{"type":96},{"type":68,"attrs":1115,"content":1117},{"id":1116},"p_pk27dnzu",[1118,1120,1124],{"text":1119,"type":74},"Every algorithm has a cost. The notation ",{"text":1121,"type":74,"marks":1122},"Big O",[1123],{"type":96},{"text":1125,"type":74}," describes how that cost grows as the input size increases.",{"type":404,"attrs":1127,"content":1129},{"id":1128},"tbl_o0rspx02",[1130,1164,1193,1221,1249,1278],{"type":409,"content":1131},[1132,1143,1154],{"type":412,"attrs":1133,"content":1134},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1135],{"type":68,"attrs":1136,"content":1138},{"id":1137},"p_tzvlp98s",[1139],{"text":1140,"type":74,"marks":1141},"Notation",[1142],{"type":96},{"type":412,"attrs":1144,"content":1145},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1146],{"type":68,"attrs":1147,"content":1149},{"id":1148},"p_fyoelqa0",[1150],{"text":1151,"type":74,"marks":1152},"Name",[1153],{"type":96},{"type":412,"attrs":1155,"content":1156},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1157],{"type":68,"attrs":1158,"content":1160},{"id":1159},"p_txkfcnul",[1161],{"text":443,"type":74,"marks":1162},[1163],{"type":96},{"type":409,"content":1165},[1166,1175,1184],{"type":449,"attrs":1167,"content":1168},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1169],{"type":68,"attrs":1170,"content":1172},{"id":1171},"p_mw55q2or",[1173],{"text":1174,"type":74},"O(1)",{"type":449,"attrs":1176,"content":1177},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1178],{"type":68,"attrs":1179,"content":1181},{"id":1180},"p_ttf71xl4",[1182],{"text":1183,"type":74},"Constant",{"type":449,"attrs":1185,"content":1186},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1187],{"type":68,"attrs":1188,"content":1190},{"id":1189},"p_4x11rh06",[1191],{"text":1192,"type":74},"Accessing array element by index",{"type":409,"content":1194},[1195,1204,1213],{"type":449,"attrs":1196,"content":1197},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1198],{"type":68,"attrs":1199,"content":1201},{"id":1200},"p_qdjqfl83",[1202],{"text":1203,"type":74},"O(log n)",{"type":449,"attrs":1205,"content":1206},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1207],{"type":68,"attrs":1208,"content":1210},{"id":1209},"p_ie47cnov",[1211],{"text":1212,"type":74},"Logarithmic",{"type":449,"attrs":1214,"content":1215},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1216],{"type":68,"attrs":1217,"content":1219},{"id":1218},"p_phc1ggz9",[1220],{"text":855,"type":74},{"type":409,"content":1222},[1223,1232,1241],{"type":449,"attrs":1224,"content":1225},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1226],{"type":68,"attrs":1227,"content":1229},{"id":1228},"p_sp6e9le2",[1230],{"text":1231,"type":74},"O(n)",{"type":449,"attrs":1233,"content":1234},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1235],{"type":68,"attrs":1236,"content":1238},{"id":1237},"p_tnuvwx2i",[1239],{"text":1240,"type":74},"Linear",{"type":449,"attrs":1242,"content":1243},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1244],{"type":68,"attrs":1245,"content":1247},{"id":1246},"p_xuf64rad",[1248],{"text":831,"type":74},{"type":409,"content":1250},[1251,1260,1269],{"type":449,"attrs":1252,"content":1253},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1254],{"type":68,"attrs":1255,"content":1257},{"id":1256},"p_qb8mkawx",[1258],{"text":1259,"type":74},"O(n log n)",{"type":449,"attrs":1261,"content":1262},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1263],{"type":68,"attrs":1264,"content":1266},{"id":1265},"p_jl8w7qtn",[1267],{"text":1268,"type":74},"Linearithmic",{"type":449,"attrs":1270,"content":1271},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1272],{"type":68,"attrs":1273,"content":1275},{"id":1274},"p_y0okt3xq",[1276],{"text":1277,"type":74},"Merge Sort, Quick Sort",{"type":409,"content":1279},[1280,1289,1298],{"type":449,"attrs":1281,"content":1282},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1283],{"type":68,"attrs":1284,"content":1286},{"id":1285},"p_ebjg2ovd",[1287],{"text":1288,"type":74},"O(n²)",{"type":449,"attrs":1290,"content":1291},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1292],{"type":68,"attrs":1293,"content":1295},{"id":1294},"p_e70kwzx2",[1296],{"text":1297,"type":74},"Quadratic",{"type":449,"attrs":1299,"content":1300},{"align":9,"colspan":414,"rowspan":414,"colwidth":9},[1301],{"type":68,"attrs":1302,"content":1304},{"id":1303},"p_uw8ci6m6",[1305],{"text":1306,"type":74},"Bubble Sort, Selection Sort",{"type":98,"attrs":1308,"content":1310},{"id":1309,"type":366,"title":9},"call_0xb0ojiy",[1311],{"type":68,"attrs":1312,"content":1314},{"id":1313},"p_5a3khxti",[1315,1319],{"text":1316,"type":74,"marks":1317},"The choice of algorithm directly impacts system performance. ",[1318],{"type":96},{"text":1320,"type":74},"An O(n²) algorithm applied to one million records is catastrophic. The same problem with O(log n) runs in milliseconds.",{"type":160,"attrs":1322},{"id":1323,"alt":9,"src":1324,"title":9,"width":9,"height":9},"img_9gx5rwsm","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002F1774680095677-26mqhn.png",{"type":88,"attrs":1326,"content":1328},{"id":1327,"level":36},"h_1nc9gb74",[1329],{"text":1330,"type":74,"marks":1331},"The Most Common Mistake of Those Starting Out",[1332],{"type":96},{"type":68,"attrs":1334,"content":1336},{"id":1335},"p_ufrhvfmw",[1337],{"text":1338,"type":74},"Most beginners try to learn programming by learning a language.",{"type":68,"attrs":1340,"content":1342},{"id":1341},"p_k2p7qsnj",[1343,1345,1349,1351,1355,1356,1360],{"text":1344,"type":74},"They memorize the syntax of ",{"text":1346,"type":74,"marks":1347},"if",[1348],{"type":246},{"text":1350,"type":74},", of ",{"text":1352,"type":74,"marks":1353},"for",[1354],{"type":246},{"text":1350,"type":74},{"text":1357,"type":74,"marks":1358},"while",[1359],{"type":246},{"text":1361,"type":74}," — but when they hit a real problem, they freeze. Because the problem is never syntax. The problem is logic.",{"type":68,"attrs":1363,"content":1365},{"id":1364},"p_nq7evsn4",[1366],{"text":1367,"type":74,"marks":1368},"The language is just notation. The algorithm is the thought.",[1369],{"type":144},{"type":98,"attrs":1371,"content":1373},{"id":1372,"type":101,"title":9},"call_806fp0vu",[1374],{"type":68,"attrs":1375,"content":1377},{"id":1376},"p_l4jlvuwz",[1378,1382],{"text":1379,"type":74,"marks":1380},"Flip the order: ",[1381],{"type":96},{"text":1383,"type":74},"first solve the problem on paper, then translate it to code. Draw the flow. Break the problem into smaller parts. Define the inputs and outputs of each part. Only then open the editor.",{"type":68,"attrs":1385,"content":1387},{"id":1386},"p_zagf8lvw",[1388],{"text":1389,"type":74},"This habit — apparently simple — is what sets apart a programmer who moves forward from one who stays stuck forever in tutorials.",{"type":88,"attrs":1391,"content":1393},{"id":1392,"level":36},"h_lhsy3x0j",[1394],{"text":1395,"type":74,"marks":1396},"Conclusion",[1397],{"type":96},{"type":68,"attrs":1399,"content":1401},{"id":1400},"p_hyt0hux0",[1402],{"text":1403,"type":74},"Algorithms and programming logic aren't college material. They're the foundation of everything you'll build as a developer.",{"type":68,"attrs":1405,"content":1407},{"id":1406},"p_7kyk3fg7",[1408],{"text":1409,"type":74},"Sequence, selection, and repetition. Data types. Well-named functions. Binary Search. Big O complexity. Planning before code.",{"type":68,"attrs":1411,"content":1413},{"id":1412},"p_iwn6w1yh",[1414],{"text":1415,"type":74},"These concepts don't go out of style. It doesn't matter if the language of the moment is C, Python, JavaScript, or whatever else emerges in the coming years — the logic behind all of them is the same.",{"type":1417,"attrs":1418},"summaryBox",{"id":1419,"items":1420,"title":1430},"sum_30tgf3lv",[1421,1422,1423,1424,1425,1426,1427,1428,1429],"Algorithm: finite, ordered sequence of steps to solve a problem.","Three control structures: sequence, selection, and repetition.","Data types: int, float, char — variables vs constants.","Functions: reusable blocks with a specific purpose.","Binary Search is O(log n) — exponentially faster than linear search.","Bubble Sort teaches the sorting patterns every advanced algorithm uses.","Recursion: base case + recursive call. Always.","Big O: the algorithm's cost determines whether the system scales or freezes.","First solve it on paper. Then open the editor.","What remains",{"type":68,"attrs":1432},{"id":1433},"p_jw0axqke","Algorithms and Programming Logic: The Developer's Map","Master programming logic before writing code. Understand algorithms, control structures, and Big O complexity.","2026-08-24T14:53:53.315534+00:00",[1438,1459,1477,1491],{"id":1439,"slug":1440,"title":1441,"excerpt":1442,"image":1443,"featured":225,"groupId":1444,"publishedAt":1445,"readingTime":1446,"views":48,"author":1447,"category":1448,"tags":1449},"81f24e9a-fc6b-47d0-beb9-d00a6137ed99","framework-vs-sdk-who-calls-whom","Framework vs SDK: Who Calls Whom","Most developers memorize names, but few understand the mechanism. Here is the simple rule to tell a framework from an SDK and level up your debugging.","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002Ffeatured\u002F1787491947099-featured-ikba2e.jpg","0ccb21eb-6459-40ed-8110-227836e9bb74","2026-08-23T13:15:25.439194+00:00",10,{"name":50,"avatar":9},{"slug":13,"name":14,"color":15},[1450,1451,1453,1456],{"slug":54,"name":55},{"slug":839,"name":1452},"Python",{"slug":1454,"name":1455},"runtime","Runtime",{"slug":1457,"name":1458},"sdk","Sdk",{"id":1460,"slug":1461,"title":1462,"excerpt":1463,"image":1464,"featured":44,"groupId":1465,"publishedAt":1466,"readingTime":1467,"views":1468,"author":1469,"category":1470,"tags":1471},"c2d6b1ca-29bf-401f-8ab9-a1f828504d0b","microfrontends-with-angular-and-nx-what-nobody-tells-you","Microfrontends with Angular and Nx: what nobody tells you","Every tutorial teaches how to set up microfrontends in minutes, but few reveal the architectural chaos that emerges after months of production deploys.","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002Ffeatured\u002F1785206853570-featured-zoyhgn.webp","3368e1b2-b6de-4e94-a3d4-294fae8ade13","2026-08-03T01:42:48.969355+00:00",15,5,{"name":50,"avatar":9},{"slug":13,"name":14,"color":15},[1472,1475,1476],{"slug":1473,"name":1474},"angular","Angular",{"slug":54,"name":55},{"slug":57,"name":58},{"id":1478,"slug":1479,"title":1480,"excerpt":1481,"image":1482,"featured":44,"groupId":1483,"publishedAt":1484,"readingTime":1485,"views":1446,"author":1486,"category":1487,"tags":1488},"36440333-311c-4081-92e6-030a04a38fed","astro-island-architecture-performance-and-where-the-framework-truly-fits","Astro: Island Architecture, Performance, and Where the Framework Truly Fits","Astro challenges the modern web status quo by prioritizing static HTML and isolating interactivity into independent, lightweight code islands.","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002Ffeatured\u002F1785721161920-featured-a5vzkb.webp","cb62459e-7ace-43d3-a545-661c5695e925","2026-08-03T01:00:45.280114+00:00",38,{"name":50,"avatar":9},{"slug":13,"name":14,"color":15},[1489,1490],{"slug":54,"name":55},{"slug":57,"name":58},{"id":1492,"slug":1493,"title":1494,"excerpt":1495,"image":1496,"featured":44,"groupId":1497,"publishedAt":1498,"readingTime":1499,"views":48,"author":1500,"category":1501,"tags":1502},"633b6488-2a90-4632-86a5-9cff7ed52f08","javascript-event-loop-the-heart-of-non-blocking-concurrency-revisited-in-2025","JavaScript Event Loop: The Heart of Non-Blocking Concurrency — Revisited in 2025","The Event Loop is not just a simple loop, but a sophisticated coordination mechanism between Call Stack, queues, and runtime. Essential for JS concurrency, it enables thousands of asynchronous operations without blocking the UI. This guide explores its structure, differences between Node.js and browsers, common bugs, advanced techniques, and 2025 trends like Structured Concurrency and scheduler.yield().","https:\u002F\u002Fmfgiomkkbihnlpfdxwrt.supabase.co\u002Fstorage\u002Fv1\u002Fobject\u002Fpublic\u002Fblog-assets\u002Fmedia\u002Ffeatured\u002F1772847201637-featured-oreiro.jpeg","df6ca967-8130-4b2d-bcac-3532a150131e","2026-07-26T18:54:25.359533+00:00",6,{"name":50,"avatar":9},{"slug":13,"name":14,"color":15},[1503,1504],{"slug":54,"name":55},{"slug":1505,"name":1506},"nodejs","Node.js",{"en":40,"pt":1508},"algoritmos-e-logica-de-programacao-o-mapa-que-todo-desenvolvedor-precisa"]