Java data structure and algorithm

catalogue recursion The concept of recursion Recursive call mechanism Print problem code   Operation results Factorial problem     Operation results Explanation of recursive call mechanism ​ Recursive call rule What kind of problems can recursion solve What kind of problem is recursion used to solve   Importan ...

Posted by trystan on Sat, 23 Oct 2021 07:37:06 -0700

Heap structure and heap sorting

Heap (priority queue) Time complexity: The time complexity of initializing heap building is O(n) Heap sort rebuild heap O(nlogn) PriorityQueue small top heap Small top heap: the weight of any non leaf node is not greater than the weight of its left and right child nodes Constructor constructor Function introductionPriorityQueue()Create a ...

Posted by rajeevbharti on Sat, 23 Oct 2021 03:06:30 -0700

< data structure Zhejiang University > 03 tree isomorphism of 1 tree (25 points)

      Give two trees T1 and T2. If T1 can be changed into T2 by several times, we call the two trees "isomorphic". For example, the two trees given in Figure 1 are isomorphic, because we exchange the left and right children of nodes A, B and G of one tree to get the other tree. Figure 2 is not isomorphic. ...

Posted by desoto0311 on Sat, 23 Oct 2021 01:31:11 -0700

(C language) stack and queue experiment

1. (1): judge whether open parentheses and closed parentheses in an arithmetic expression are paired. Implementation code: #include <stdio.h> #include <stdlib.h> #define MAXSIZE 100 typedef struct{ char data[MAXSIZE]; int top; }seqstack; int MatchCheck(char str[]){ seqstack s; int i = 0; s.top = -1; while (str[i] != '\0'){ ...

Posted by lou28 on Fri, 22 Oct 2021 23:02:39 -0700

Deep understanding of red black tree addition and deletion nodes

Purpose: It is mainly used in key value search mapnginx Timer event managementEpoll event block managementcfsmemory management Like malloc Sketch Map Red black tree characteristics: 1, Each node is red or black 2, The root node is black 3, Each leaf node is black and hidden 4, If a node is red, its child nodes are black 5, For a node, all ...

Posted by prc on Fri, 22 Oct 2021 22:40:48 -0700

Python data structure 02 - sequential list, linked list

Sequence table Storage method of elements in the sequence table: The complete information of the sequence table consists of two parts: 1. Set of elements in the table 2. Information on the overall situation of the table There are two ways to implement the sequence table: Figure a shows an integrated structure: table information and el ...

Posted by ignorant on Fri, 22 Oct 2021 08:00:19 -0700

Python data structure and algorithm -- search and sort

search 1. Sequential search Through subscripts, we can access and search data items in order. This technology is called "sequential search" def sequentialSearch(alist,item): pos = 0 found = False while pos<len(alist) and not found: if alist[pos] == item: found = True else: ...

Posted by renzaho on Fri, 22 Oct 2021 02:47:21 -0700

Standard template library for solving algorithm problems

Monotone stack handles the problem of size comparison in the overall O(n) time by maintaining the monotonic increment (decrement) of the value in the stack. 739 daily temperature Given the daily temperature, it is required to wait a few days for each day to wait for a warmer day. If there is no warmer weather after that day, it is recorded as ...

Posted by r3dk1t on Thu, 21 Oct 2021 22:53:03 -0700

Sequential storage structure of sequential table

Sequential storage definition Speaking of so many linear tables, let's take a look at the first of the two physical structures of linear tables - sequential storage structure. The sequential storage structure of linear table refers to the sequential storage of data elements of linear table with a section of storage units with continuous addres ...

Posted by carlg on Thu, 21 Oct 2021 21:38:49 -0700

[data structure] linked list (single linked list implementation + detailed explanation + original code)

catalogue preface Linked list Concept and structure of linked list Classification of linked lists 1. One way or two-way 2. Lead or not lead   3. Cyclic or non cyclic Implementation of single linked list Print linked list Application node Tail insertion Head insert Tail deletion Header deletion Insert after specified positi ...

Posted by ddragas on Thu, 21 Oct 2021 07:06:01 -0700