[data structure] linked list 04: LeetCode 21. Merge two ordered linked lists, LeetCode 23. Merge K ascending linked lists

1, LeetCode 21. Merge two ordered linked lists Method 1: iteration Code and performance class Solution { public ListNode mergeTwoLists(ListNode l1, ListNode l2) { ListNode dummy = new ListNode(-1); ListNode p = dummy; ListNode p1 = l1; ListNode p2 = l2; while(p1 != null && p2 != null){ ...

Posted by troybtj on Sun, 28 Nov 2021 09:21:52 +0100

Binary search tree and balanced binary tree

Write in front We talked about the basic concept of tree. This article mainly talks about the basic operations of common trees, such as finding, adding, deleting, etc. It is easier to understand by moving graph. Binary lookup tree Binary Sort Tree (BST), also known as Binary Sort Tree, or binary search tree. A binary lookup tree satisfies the f ...

Posted by sphinx9999 on Sun, 28 Nov 2021 05:52:45 +0100

Detailed explanation of RequestBodyAdvice and ResponseBodyAdvice, @ ControllerAdvice annotation

overview RequestBodyAdvice RequestBodyAdvice is an interface provided by spring mvc4.2, which allows the request body to be read and converted into an object, and takes the processing result object as the @ RequestBody parameter or the @ HttpEntity method parameter. It can be seen that its scope of action is: Parameters marked with @ RequestB ...

Posted by hookit on Sat, 27 Nov 2021 05:25:33 +0100

[data structure] Huffman tree & Huffman coding

Huffman tree definition: Given N weights as N leaf nodes, a binary tree is constructed. If the weighted path length of the tree reaches the minimum, such a binary tree is called the optimal binary tree, also known as Huffman tree. Huffman tree is the tree with the shortest weighted path length, and the node with larger weight is closer to th ...

Posted by glennn3 on Sat, 27 Nov 2021 04:36:33 +0100

Array ring queue of data structure (Java implementation)

When an array simulates a queue, there will be a problem that it cannot be reused. Here, a ring queue is used to solve the problem. Because the simulation is a ring queue, let's adjust the meaning of each attribute in the queue. 1. Analysis:   The original acyclic queue (non ring queue) cannot store data when the tail pointer of rear reac ...

Posted by nsbrown on Fri, 26 Nov 2021 11:50:02 +0100

An article takes you to understand the stack

Stack Definition of stack Stack is a linear table with limited operation. It can only enter or output elements from one end. It has the property of * * last in first out (LIFO) * *. The first data is pushed into the bottom of the stack, and the last data is at the top of the stack. When you need to read data, POP up data from the top of the s ...

Posted by ziv on Fri, 26 Nov 2021 05:00:18 +0100

Network programming based on TCP

C/S program of TCP protocol Two classes need to be used to write CS programs of TCP protocol: ServerSocker build serverSocker build client During network construction, there must be a server first, and then we can build a client connection server. Two classes are described below: ServerSocker It is used to create a server. After creat ...

Posted by tidou on Thu, 25 Nov 2021 00:05:41 +0100

Chapter 8 search algorithm

Chapter 8 search algorithm 1. Introduction to search algorithm Sequential (linear) lookup Binary search / half search Interpolation lookup fibonacci search 2. Linear search Write linear search algorithm code public class SeqSearch { public static void main(String[] args) { int[] arr = { 1, 2, 3, 4, 5 };// Array without order int inde ...

Posted by grimz on Wed, 24 Nov 2021 14:39:36 +0100

Huffman tree (optimal binary tree)

Basic introduction: 1) to set n Weights as n individual leaf node , construct a binary tree if the Weighted path length degree ( wpl ) reach To the minimum, such a binary tree is called Optimal binary tree , also known as Huffman tree (Huffman Tree ) 2) Hector husband Man tree It is the tree with the shorte ...

Posted by tHud on Tue, 23 Nov 2021 16:18:20 +0100

Summary of data structure knowledge points and common test examples

7, Figure Basic concept of graph 1. Graph: graph G is composed of two sets V and E, marked as G=(V,E), where V is a finite nonempty set of vertices and E is a finite set composed of ordered pairs of vertices in V. these ordered pairs are called edges or arcs 2. Undirected graph 3. Directed graph 4. Complete graph: if there are edges ...

Posted by ow-phil on Tue, 23 Nov 2021 15:52:24 +0100