Chapter Six, Tree Learning Notes

Tree: A tree is a finite set of n(n < 0) nodes. n=0 is called an empty tree. In any non-empty tree: (1) there is only one specific node called Root; (2) When n>1, the remaining nodes can be divided into m(m>0) finite disjoint sets.Each of these collections is itself a tree and is called a SubTree of the root. 1. When n > 0, the ...

Posted by rushdot on Sat, 05 Feb 2022 18:31:22 +0100

NC51 merges k sorted linked lists

NC51 merges k sorted linked lists Solution 1: use auxiliary array Traverse each linked list and push the val value of the node into the array arr Sort arr Convert the sorted array into a linked list Return header node head Time complexity: traverse all nodes O(n), sort O(nlogn) Space complexity: use an array with the same length as the ...

Posted by PJSheltrum on Sat, 05 Feb 2022 12:07:20 +0100

[XJTUSE] data structure learning -- 3.4 binary search tree

3.4 binary search tree The function of binary search tree one ️⃣ Provides the ability to find elements that take logn time two ️⃣ Provides the ability to insert and delete elements taking logn time For 10000 data ■ using a linear table to find elements requires an average of 5000 comparisons ■ using binary search tree to find el ...

Posted by Hoangsta on Sat, 05 Feb 2022 10:32:57 +0100

Monotone queue and monotone stack

1, Monotone queue 1. Monotone queue introduction Monotone queue refers to a data structure in which the elements in a queue have strict monotonicity. It is divided into monotone increasing queue and monotone decreasing queue. Monotone queues satisfy two properties: (1) The monotone queue must satisfy the strict monotonicity from the head ...

Posted by ricroma on Sat, 05 Feb 2022 10:32:20 +0100

L2-002 linked list weight removal (25 points)

L2-002 linked list weight removal (25 points) Given a linked list L with integer key values, you need to delete the key value nodes with duplicate absolute values. That is, for each key value K, only the node with the first absolute value equal to K is retained. At the same time, all deleted nodes must be saved in another linked list. For exam ...

Posted by deadonarrival on Fri, 04 Feb 2022 15:16:59 +0100

Priority queue (heap)

catalogue 1, What is a pile? 2, Create a large root heap using an array: 3, What is the time complexity of building a heap? 4, PriorityQueue: summary preface Previously, we learned about trees and binary trees. We learned that there is a special kind of tree called complete binary tree. If it is a complete binary tree, it can be sto ...

Posted by CodeMaster on Fri, 04 Feb 2022 13:18:41 +0100

[XJTUSE] data structure learning - 3.3 Huffman tree

3.3 Huffman tree Basic concepts Path length: the number of branches on the path between two nodes External path length of the tree: the sum of the path length from each leaf node to the root node Internal path length of the tree: the sum of the path length from each non leaf node to the root node Weighted path length of tree: the sum o ...

Posted by amorphous on Fri, 04 Feb 2022 12:40:55 +0100

Algorithm self-study notes: binary search tree search operation

In this paper, we continue to build a binary tree, and the rest of the methods API: size() returns the total number of nodes select(int k) returns the key ranked K in the tree, that is, K keys are less than it Rank (key) returns the ranking of a given key, that is, the number less than the key in the tree To implement these methods, we ...

Posted by magie on Fri, 04 Feb 2022 08:56:12 +0100

[C + +] binary search tree

Today we will talk about a special binary tree, binary search tree. Learning binary search tree well will help us understand and master map and set later. Binary search tree concept Binary search tree, also known as binary sort tree, is either an empty tree or a binary tree with the following properties: If its left subtree is not empty, ...

Posted by bigshwa05 on Fri, 04 Feb 2022 08:31:05 +0100

Data structure -- Huffman tree and its application

Basic concepts of Huffman   Path: the branch from one node to another in the tree forms the path between the two nodes Node path length: the number of branches on the path between two nodes   Path length of tree: the sum of the path length from the tree root to each node is recorded as TL In the binary tree with the same number of n ...

Posted by amarquis on Fri, 04 Feb 2022 06:17:58 +0100