Graph theory search: how to use multi-source BFS to reduce time complexity

In graph theory search, single source BFS and multi-source BFS search distance. 1. BFS graph theory search question in leetcode leetcode link: 1162. Map analysis You now have a grid with a size of n x n, and each cell on it is marked with 0 and 1. Where 0 represents the ocean and 1 represents the land. Please find an ocean cell. The dist ...

Posted by rich11 on Tue, 01 Feb 2022 18:56:12 +0100

[Luogu] 1967 truck transportation (Kruskal + Chain forward star + double LCA)

1, Title Description 2, Problem solving ideas Originally, the simple Kruskal algorithm timed out. After watching the method of the great gods, I learned the chain forward star and multiplication LCA for the first time. The following chain forward star and multiplication LCA are introduced in detail below 3, Chain forward star Chained forw ...

Posted by Josepheuan on Tue, 01 Feb 2022 18:52:52 +0100

Data structure and algorithm learning note search

Data structure and algorithm learning notes (9) search I Basic concepts of search Lookup table What is find How to find Purpose of search Classification of lookup tables Evaluation index of search algorithm Research content of search process II Lookup of linear table 1. Sequential search Scope of application Static l ...

Posted by Zup on Tue, 01 Feb 2022 17:48:14 +0100

Freecodecamp JavaScript elementary algorithm question-2

Then continue to write the last article.5. Find the largest number in multiple arraysInput: largestOfFour([[13, 27, 18, 26], [4, 5, 1, 3], [32, 35, 37, 39], [1000, 1001, 857, 1]])Output: [27, 5, 39, 1001]Solution:function largestOfFour(arr) { let temp = []; for(let i =0;i<arr.length;i++) { temp.push(Math.max(...arr[i])); } return ...

Posted by syed on Tue, 01 Feb 2022 17:21:37 +0100

[assembly series-1] basic program structure of assembly language and helloworld example (including the basic usage of "most simplified program" presentation process proc and macro)

When I first started to study the course of microcomputer principle, I had a feeling that I couldn't start with assembly language programming. After a semester of practice, I am familiar with the assembly language. I want to organize an article to help the assembly Xiaobai who has just started. 1, Programming environment Let's briefly mention ...

Posted by rlalande on Tue, 01 Feb 2022 17:12:07 +0100

OJ topic 2 -- recursion in nested form

The so-called nested form of recursion, according to my understanding, is that the form of recursion is relatively complex, which can not be made clear in a simple sentence. This requires two layers of recursion for nesting to achieve the purpose. For example, to calculate the number of nodes in a binary tree, the fundamental logic to solve thi ...

Posted by rledieu on Tue, 01 Feb 2022 15:12:18 +0100

Linked list problem, how to deliver the turtle gracefully?

preface Hello, I'm "programmer bear" from Huawei. Most children's shoes know that when solving problems related to "linked list", the commonly used problem-solving routines mainly include "double pointer", "iteration" and "virtual head node". Today, "Little Bear" introduces the strat ...

Posted by manchuwok on Tue, 01 Feb 2022 13:24:15 +0100

Dichotomy summary (super detailed) with illustration

1. Dichotomy Binary search is an algorithm with high time efficiency. Especially in the face of a large amount of data, its search efficiency is very high and the time complexity is log(n). The main idea is to keep folding in half. Half of the data can be removed each time. Finally, all unqualified results are removed, leaving only one ...

Posted by mikebyrne on Tue, 01 Feb 2022 12:34:07 +0100

Kiner algorithm brush inscription: fast platoon and fast platoon idea (hand tearing algorithm)

Guide to series of articles Guide to series of articles preface After we are familiar with the idea and implementation principle of quick sort, we can bring a lot of inspiration and inspiration in our actual development. With the idea of double pointer walking of quick sort, we can also solve many kinds of quick sort problems. Now let's use ...

Posted by wvwisokee on Tue, 01 Feb 2022 08:41:52 +0100

Data structure and algorithm (Java implementation) [hash table]

1. Introduction 2. Hash table (- 1) related terms 1. Hash method (hash method) Select a function, calculate the storage location of elements by keyword according to the function, and store them according to this. When searching, the same function calculates the address of the given value k, and compares k with the key value of the element ...

Posted by mart on Tue, 01 Feb 2022 08:37:30 +0100