随笔分类 - Algorithms
摘要:Let's say we have two strings: str1 = 'ACDEB' str2 = 'AEBC' We need to find the longest common subsequence, which in this case should be 'AEB'. Using
阅读全文
摘要:The k-nearest neighbors algorithm is used for classification of unknown items and involves calculating the distance of the unknown item's neighbors. W
阅读全文
摘要:Every dynamic programming algorithm starts with a grid. It entails solving subproblems and builds up to solving the big problem. Let’s break down a pr
阅读全文
摘要:Binary search is an algorithm that accepts a sorted list and returns a search element from the list. It provides a dramatic performance boost over sea
阅读全文
摘要:Merge sort is a recursive sorting algorithm. If you don't understand recursion, I recommend finding a resource to learn it. In brief, recursion is the
阅读全文
摘要:nsertion sort is another sorting algorithm that closely resembles how we might sort items in the physical world. We start at the second item in our co
阅读全文
摘要:A binary tree is a tree where each node may only have up to two children. These children are stored on the leftand right properties of each node. When
阅读全文
摘要:Quicksort (also called partition sort and pivot sort) is arguably the most used sorting algorithm. It is the one commonly implemented internally in la
阅读全文
摘要:In a tree, nodes have a single parent node and may have many children nodes. They never have more than one parent nor point to any siblings. The most
阅读全文
摘要:Depth first search is a graph search algorithm that starts at one node and uses recursion to travel as deeply down a path of neighboring nodes as poss
阅读全文
摘要:Recursion is when a function calls itself. This self calling function handles at least two cases, the recursive case and the base case. People seem to
阅读全文
摘要:Breadth first search is a graph search algorithm that starts at one node and visits neighboring nodes as widely as possible before going further down
阅读全文
摘要:A graph is a data structure comprised of a set of nodes, also known as vertices, and a set of edges. Each node in a graph may point to any other node
阅读全文
摘要:A linked list is a collection of items where each item points to the next one in the list. Because of this structure, linked lists are very slow when
阅读全文
摘要:A stack is a collection of items that obeys the principle of "last in, first out". Like a stack of plates, we can only access the topmost plate at any
阅读全文
摘要:In this lesson, you will learn how to create a queue in JavaScript. A queue is a first-in, first-out data structure (FIFO). We can only remove items f
阅读全文
摘要:Insertion sort is a very intuitive algorithm as humans use this pattern naturally when sorting cards in our hands. In this lesson, using TypeScript /
阅读全文
摘要:A palindrome is a string that reads the same forward and backward, for example, radar, toot, and madam. In this lesson we discuss how to approach the
阅读全文
摘要:The anagram test is commonly used to demonstrate how an naive implementation can perform significant order of magnitudes slower than an efficient one.
阅读全文
摘要:Prior odd: The idea is to take the odds for something happening (against it not happening), which we´ll write as prior odds. For example: The chances
阅读全文