Sparse arrays and queues
3.1 sparse array
3.1.1 first look at a demand
The Gobang program has the functions of saving, exiting and continuing the upper board. Analyze the problem: Because many values of two-dimensional array are the default value of 0, many meaningless data = = > sparse array are recorded.
3.1.2 basic introduction
When most elements in an array ...
Posted by liquidmind on Thu, 10 Feb 2022 23:03:41 +0100
Algorithm analysis and design of Beihang 2020-C2
Say at the beginning
This blog only provides learning materials and my personal review. In the process of learning algorithms, the code should be typed by myself. It is not convenient to copy and paste the code directly. Copy code without harm.
preface
The original intention of writing this series of blogs is that the process of learning alg ...
Posted by plaggypig on Thu, 10 Feb 2022 22:33:22 +0100
Notes on sword finger offer JZ1-5
A references
Book "sword finger offer (Second Edition)"
Search in JZ01 binary array
1. Title Description
In a two-dimensional array (each one-dimensional array has the same length), each row is sorted in ascending order from left to right, and each column is sorted in ascending order from top to bottom. Please complete a function, ...
Posted by sentback on Thu, 10 Feb 2022 18:21:25 +0100
Java collection source code analysis: ArrayList
After so much preparation, it finally started. Ha, ArrayList Kaigan! ArrayList should be the most frequently used collection class. Let's take a look at how the document introduces it. We can know that ArrayList is actually a replica of Vector, but it only removes thread safety. ArrayList is a List implementation that can be dynamically resize ...
Posted by magie on Thu, 10 Feb 2022 17:56:56 +0100
Blue Bridge Cup [real exercise] weight of complete binary tree
[problem description]
Given a complete binary tree with N nodes, each node in the tree has a weight, which is A1, A2, ···· AN from top to bottom and from left to right, as shown in the following figure:
Now Xiao Ming wants to add up the weights of nodes with the same depth. He wants to know which depth has the ...
Posted by fluvius on Thu, 10 Feb 2022 14:52:25 +0100
Implementation and application of [data structure] stack Python code example
catalogue
The stack is implemented as follows:
Several practical applications of stack
The stack is implemented as follows:
Method 1: take the tail of the list as the top of the stack, and use the list method append and pop to realize the stack
class Stack:
def __init__(self): #Initialization class
self.items=[]
def isE ...
Posted by broann on Thu, 10 Feb 2022 12:27:32 +0100
Python finds substrings in strings
This is a question that Xiaobai blogger encountered when brushing leetcode. This is the best question in the leetcode question bank recently, so I share this joy here.
I hope I can continue to make progress and persevere in the future.
catalogue
Topic introduction
Problem solving ideas and codes
1. Call function - find/index
2. Viole ...
Posted by CrusaderSean on Thu, 10 Feb 2022 12:03:57 +0100
[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
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
Linked list related interview questions Chapter 2
Catalogue of series articles
preface
1, Circular linked list
Circular linked list
1. Title Description
Given a linked list, judge whether there are links in the linked list.If there is a node in the linked list that can be reached again by continuously tracking the next pointer, there is a ring in the linked list. In order ...
Posted by edtlov on Wed, 09 Feb 2022 22:19:31 +0100