[data structure] algorithm: heap sorting

preface Heap sort is a sort method with time complexity of O(nlgn). The data structure "heap" is used. This article will answer what is "heap"? How to sort with "heap"? Binary reactor First, let's answer what is "heap". Heap is usually an array object that can be regarded as a complete binary tree. It ...

Posted by gabeg on Thu, 10 Feb 2022 10:59:20 +0100

Binary search (solve your problem of judging from scratch for loop with the least steps)

WHAT? Suppose you want to find a person whose name starts with K in the phone book, (who still uses the phone book now!) You can turn the page from the beginning until you enter the part starting with K. But you probably don't do that, but start in the middle, because you know the name starting with K is in the middle of the phone book. Suppo ...

Posted by foreverhex on Thu, 10 Feb 2022 06:34:17 +0100

String matching Pabinkarp

Title: Judge whether the string s contains the string p. The input takes up two lines: String s and string p. The output contains the starting subscript of string p in string s. if there are multiple matches, all of them will be output, and each output will occupy one line. Case: Input: ABABABA ABA Output: 0 2 4 Preliminarily explore t ...

Posted by defect on Thu, 10 Feb 2022 06:11:37 +0100

LeetCode#36. Effective Sudoku

Title: Please judge whether a Sudoku of {9 x 9 is effective. You only need to verify whether the numbers you have filled in are valid according to the following rules. The numbers , 1-9 , can only appear once in each line. The numbers ^ 1-9 ^ can only appear once in each column. The numbers ^ 1-9 ^ can only appear once in each ^ 3x3 ^ ...

Posted by crowezr on Thu, 10 Feb 2022 04:47:54 +0100

2022-02-09 swipe questions and punch in every day

1, ACWing: 01 knapsack problem (1) Title Description          There are # NN items and a backpack with a capacity of # VV #. Each item can only be used once. The volume of item , ii , is , vivi and the value is , wi. Solve which items are loaded into the backpack, so that the total volume of these items does not exceed the backpack cap ...

Posted by linuxdream on Thu, 10 Feb 2022 04:26:53 +0100

Python data structure 6: queue concept and implementation, double ended queue concept and implementation, hot potato algorithm, method of judging palindromes

1. Concept and nature of queue 1.1 definition: Queue is an ordered data set, which is characterized by The addition of new data items always occurs at one end (often referred to as the "tail end")The removal of existing data items always occurs at the other end (usually referred to as the "first front" end) When the data ...

Posted by Foregone96 on Thu, 10 Feb 2022 03:55:52 +0100

[force buckle] the binary tree is transformed into the next node of the linked list binary tree. The binary tree and the path with a certain value print the binary tree into multiple lines

Brush on the buckle these days Some binary tree problems, rely on the basis (pre order traversal ~ middle order traversal ~ subsequent traversal ~ sequence traversal) to solve the problem. Of course, there are many methods to solve the problem.    [introduce the basic traversal first] Preorder traversal The first step is to ...

Posted by neller on Thu, 10 Feb 2022 03:26:03 +0100

Understanding of ten classic sorting algorithms, dynamic graph demonstration and Python method implementation

Recently, I have worked hard to find resource animation to summarize the classic sorting algorithm. Some animations have not been found yet, but I will continue to update them later, which is suitable for beginners. Overview of sorting algorithm Sorting: adjust a group of "unordered" record sequences to "ordered" record se ...

Posted by deurwaarder on Thu, 10 Feb 2022 00:58:39 +0100

Experiment 4 of operating system requests paging storage management

Experiment 4 of operating system requests paging storage management Title Description: 1, Experimental purpose By writing the simulation program of paging storage management, deepen the understanding of paging storage management mode, be familiar with the conversion process from logical address to physical address, master the page scheduling a ...

Posted by Banacek on Wed, 09 Feb 2022 22:43:42 +0100

Python digital analog notes - NetworkX conditional shortest path

1. Shortest path problem with conditional constraints The shortest path problem is to find the shortest path between two vertices in graph theory. It is usually to find the shortest weighted path. Conditional shortest path refers to the shortest path with constraints and restrictions. For example, vertex constraints, including restrictions on ...

Posted by clio-stylers on Wed, 09 Feb 2022 20:34:43 +0100