Algorithms Every Developer Should Learn

01 BINARY SEARCH

Python Coding Example :

First, we use the iterative approach to implement a binary search. Wel'll cycle through the list, repeating a sequence of statements. We'll continue searching for the center value until we find it. 

Pertama, kami menggunakan pendekatan iteratif untuk mengimplementasikan pencarian biner. Kami akan menelusuri daftar, mengurangi urutan pernyataan. Kami akan terus mencari nilai tengah sampai kami menemukannya.

This is a python implementation of the iterative binary search function approach. If 'search_num' is present in the given list, it return one; otherwise, it gives -1. We constructed the binary search() function in this program, which accepts two arguments; a list to sort and a number to search. We've set up two variable to keep track of the list's lowest and greatest values. The low has a starting value of 0, the high has a value of len (list1)-1, and the middle has a value of 0. The while loop is then written with the constraint that the lowest equals and is smaller than the highest. The while loop will iterate if the number hasn't been found yet. The midpoint is found in the while loop. Then we match the index value to the number we've been looking for. If the mid-index value is less than 'search_num', we assign it to and raise the mid-index value by one. The focus of the search changes to the left. Set the mid value to the maximum if it is high. Return mid if the 'search_num' is equal to the mid value. This will continue until the low and high are equal and the low is smaller than the high. If we get to the end of the function, we know that the element isn't in the list. To the invoking function, we return -1.

Ini adalah implementasi python dari pendekatan fungsi pencarian biner berulang. Jika 'search_num' ada dalam  daftar yang diberikan, ia mengembalikan satu; jika tidak, itu memberikan -1. Kami membangun fungsi binary search() dalam program ini, yang menerima dua argumen; daftar untuk diurutkan dan nomor untuk dicari. Kami telah menyiapkan dua variabel untuk melacak nilai terendah dan terbesar daftar. Rendah memiliki nilai awal 0, tinggi memiliki nilai len(list1)-1, dan tengah memiliki nilai 0. Perulangan while kemudian ditulis dengan batasan bahwa yang terendah sama dengan yang dan lebih kecil dari yang tertinggi. Perulangan while akan berulang jika nomor belum ditemukan. Titik ditemukan dalam perulangan while. Kemudian kita cocokkan nilai indeks dengan angka yang kita cari. Jika nilai indeks tengah kurang dari 'search_num', kami menetapkannya dan menaikkan nilai indeks tengah satu per satu. Fokus pencarian berubah ke kiri. Atur nilai tengah ke maksimum jika tinggi. Kembalikan pertengahan jika 'search_num' sama dengan nilai tengah. Ini akan berlanjut sampai rendah dan tinggi sama dan rendah lebih kecil dari tinggi. Jika kita sampai ke akhir fungsi, kita tahu bahwa elemen tersebut tidak ada dalam daftar. Untuk fungsi pemanggilan, kami mengembalikan -1.
 

Binary Search
How you can see that required number is found at index position 2. 
 
Disini kamu dapat melihat bahwa nomor yang diperlukan ditemukan di posisi indeks 2.

Binary search is one of the first things taught in any computer science class. It is perhaps the simplest example of how a little bit of ingenuity can make things, quite literally, exponentially more efficient. 
 
Binary search adalah salah satu hal pertama yang diajarkan di setiap kelas ilmu komputer. Ini mungkin contoh paling sederhana tentang bagaimana sedikit kecerdikan dapat membuat sesuatu, secara harfiah, lebih efisien secara eksponensial. 

02 Selection, Bubble, and Insertion Sort

Python Coding Example :

 
Selection Sort

Output Selection Sort
 
Bubble Sort

Output Bubble Sort

Insertion Sort

Output Insertion Sort

Sorting algorithms are one of the most fundamental tools that a developer should have in their arsenal. Selection, Bubble, and insertion sort are some of the first that new developers should work through.
 
Sorting algorithms adalah salah satu alat paling mendasar yang harus dimiliki developer di peralatan tempur mereka. Selection, Bubble and Insertion sort adalah beberapa yang pertama, yang harus dikerjakan oleh developer baru.

03 Quicksort and Mergesort

Sorting algorithms are great for getting comfortable with arrays. But Quicksort and Mergesort are efficient enough to be used in serious applications. Being comfortable implementing these sorting algorithms are essential to being a serious developer.
 
Sorting algorithms sangat bagus untuk membiasakan diri dengan aray. Tetapi Quicksort dan Mergesort cukup efisien untuk digunakan dalam aplikasi serius. Menjadi nyaman menerapkan sorting algorithms ini sangat penting untuk menjadi developer yang serius.

04 Huffman Coding

Huffman coding is the foundation of modern text compression. it works by considering how ofter differend characters appear in a text, and organizes them in a tree based on this frequency.

Huffman coding adalah dasar dari kompresi teks modern. ini bekerja dengan mempertimbangkan seberapa sering karakter yang berbeda muncul dalam teks, dan mengaturnya dalam pohon berdasarkan frekuensi ini.

05 Breadth First Search

Breadth first search works by exploring a tree level by level until the target node is found. Since it literally going through every level it is guaranteed to find a solution.

Breadth first search bekerja dengan menelusuri pohon level demi level hingga node target ditemukan. Karena benar-benar melalui setiap level, dijamin untuk menemukan solusi.

06 Depth First Search

Depth first search is the other main approach for finding an element in a tree. Instead of working down the tree level by level. It explores the tree branch by branch.

Depth first search adalah pendekatan utama lainnya untuk menemukan elemen di pohon. Alih-alih bekerja di bawah pohon tingkat demi tingkat. Ini menjelajahi cabang pohon dengan cabang.

07 Dijkstra's Algorithm

Dijktra's algorithm is a way of finding the quickest path between two nodes in a graph. It is the foundation of most work done in path finding and finds itself used in anything from artificial intelligence to game design.

Dijkstra's algorithm adalah cara untuk menemukan jalur tercepat antara dua node dalam sebuah graf. Ini adalah dasar dari sebagian besar pekerjaan yang dilakukan dalam pencarian jalur dan menemukan dirinya digunakan dalam segala hal mulai dari kecerdasan buatan hingga desain game.

08 Diffie-Hellman Key Exchange

The Diffie-Hellman Key Exchange is a great introduction to how cryptography tends to work. More specifically, a Diffie-Hellman Key Exchange works by combining public and private keys to encrypt information.
 
The Diffie-Hellman Key Exchange adalah pengantar yang bagus tentang bagaimana kriptografi cenderung bekerja. Lebih khusus lagi. Diffie-Hellman Key Exchange bekerja dengan menggabungkan kunci publik dan pribadi untuk mengenkripsi informasi.