Directory 1. Learning points 2. The problem of finding coins 2.1 Overview 3. Event arrangement issues 3.1 Strategy selection 3.2 Program code for event arrangement issues 3.3 Generally use mathematical induction to prove 3.4 Propositions of activity selection algorithm 3.4.1 First check whether it is correct when k=1 3.4.2 Induction step, k->k + 1 3.4.3 […]
Tag: greedy-algorithm
36. Knight travel algorithm and its optimization based on greedy algorithm
Overview The knight’s traveling algorithm is called the “horse stepping on the chessboard algorithm” which may be more intuitive. In the chess 8×8 chessboard, the knight also moves in the “Japanese” pattern, which leads to a question: “If the knight is required to enter each square only once, how does it need to move through […]
Experiment 3–Design and Analysis of Greedy Algorithm
The third experimental report of an algorithm course in an unknown school The question comes from Likou. This experiment is a greedy algorithm. Greedy thinking is very jumpy, and there is no fixed template thinking direction for each question. Jumping Game Topic description: Given an array of non-negative integers, you are initially at the first […]
NPC series of articles (1)—A greedy algorithm for the minimum coverage problem Set Cover Problem
QT = core CONFIG+=c++17 cmdline # You can make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. #DEFINES + = QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES + = \ main.cpp \ simplegraph.cpp # Default rules for deployment. qnx: […]
[Code Random Record] d31-greedy algorithm-part01-python
1. Theoretical basis of greedy algorithm 1.1 What is greed? The essence of greed is to select the local optimum at each stage to achieve the global optimum. 1.2 Greedy routine Greedy algorithm has no fixed routine How to verify whether the greedy algorithm can be used? The best strategy is to give counterexamples. If […]
Greedy Algorithm ①–Use greedy algorithm ideas to solve activity scheduling problems-python
”’ 1. Having a greedy selection structure Complex problems can be broken down into smaller ones to solve 2. Has the nature of greedy selection Can we use greedy selection to start an optimal starting point? Can we use greedy selection to get a complete solution? Case 1: Optimal loading problem There are n containers […]
321. Splice the maximum number – enumerate all groups – monotonic stack + greedy algorithm
Splice the maximum number – enumerate all groups – monotonic stack + greedy algorithm Given two arrays of length m and n respectively, their elements consist of 0-9, representing the digits in each bit of the two natural numbers. Now select k (k
Greedy algorithm: 455. Distributing cookies, 376. Swing sequence, 53. Maximum subarray sum
Tips: Live hard and have a happy day Article directory 455. Distributing cookies Problem-solving ideas Problems encountered Code Summary of the question 376. Swing sequence Problem-solving ideas Problems encountered Code Summary of the question 53. Maximum subarray sum Problem-solving ideas Problems encountered Code Summary of the question Today’s experience 455. Distributing cookies Question link: 455. […]
Algorithm Design and Analysis: Greedy Algorithm
Greedy selectivity: What is greedily selected at each step must be part of the optimal solution to the original problem. Optimal substructure: After each step of greedy selection, sub-problems will remain. The optimal solution to the sub-problem and the greedy-selected solution can be combined into the optimal solution to the original problem. Recommended articles: https://www.cnblogs.com/whsu/p/13906447.htmlhttps://blog.csdn.net/ZhifanSk/article/details/105217963 […]
35. A brief discussion on greedy algorithm
Overview I believe everyone has heard of the greedy algorithm more or less. Today we will start with an application scenario. Assume that there are the following broadcast stations that require payment, and the areas that the broadcast station signals can cover. How to select the fewest broadcast stations so that all areas can receive […]