java data structure–heap

Table of Contents 1. Concept 2. The three most important methods in the heap 3. Big top pile 4. Implementing a large top heap based on arrays 5. Heap sort 6. Small top pile 7. Implement small top heap based on array 8.ProiorityQueue and Heap Example: 9. Find the Kth largest element in the array […]

[Data Structure] Heap sorting and top-K problem

Heap implementation source code #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> #include <time.h> #include <stdbool.h> #include <assert.h> typedef struct Heap {<!– –> int* a; int size; int capacity; }Heap; void HeapInit(Heap* st) {<!– –> st->a = NULL; st->capacity = 0; st->size = 0; } void swap(int* str1, int* str2) {<!– –> int tmp = *str1; *str1 […]

[TopK problem] Heap-based method & divide-and-conquer strategy-based method

Description: TopK problem: For a given array, select the largest/smallest k elements, or select the kth largest/kth smallest element; This article summarizes two implementation methods, namely Heap-based implementation method: Different from heap sorting, only by constructing a heap containing k elements, the largest/minimum k elements are finally obtained. Method based on divide and conquer strategy: […]

Data structure-binary tree·heap (implementation of sequential structure)

Personal business card: About the author: A sophomore student who is willing to share what he has learned on the road of study. Personal homepage: GOTXX Personal WeChat: ILXOXVJEThis article is original by GOTXX and first published on CSDN Column series: Learning C language from scratch —– The road to learning data structuresWord of the […]

Design and analysis of computer algorithms – data structures (tables, queues, heaps, stacks, sets, graphs, trees)

Simply put Data structures are essential tools in computer science for organizing and manipulating data efficiently. In this blog post, we will discuss the design principles and concepts behind the following data structures: tables, queues, stacks, sets, graphs, and trees. Tables: Tables, also known as arrays or matrices, are one of the simplest and most […]

Why does Java NIO cause off-heap memory OOM?

Why does Java NIO cause off-heap memory OOM? Description One day, an alarm was issued: a service deployed on a certain machine was suddenly inaccessible. Remember to log in to the machine and check the logs as the first reaction, because the service is down, most likely due to OOM. At this time, the following […]

Data structure – (heap) PriorityQueue

Table of Contents Preface 1. What is a heap? 1.1 Heap storage method 2. Creation of heap 2.1: We build the heap using the downward adjustment method: 2.2: Time complexity of building a heap Three: Heap method 3.1: Insertion into the heap 3.2: Deletion of heap Four: Use heap simulation to implement priority queue Summarize […]