Rename the common modules in Java, C++ and C.

This commit is contained in:
krahets 2023-04-24 04:11:18 +08:00
parent c6eecfd0dc
commit 145975b335
120 changed files with 122 additions and 380 deletions

View File

@ -5,7 +5,6 @@ set(CMAKE_C_STANDARD 11)
include_directories(./include)
add_subdirectory(include)
add_subdirectory(chapter_computational_complexity)
add_subdirectory(chapter_array_and_linkedlist)
add_subdirectory(chapter_stack_and_queue)

View File

@ -4,7 +4,7 @@
* Author: MolDuM (moldum@163.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 随机返回一个数组元素 */
int randomAccess(int *nums, int size) {

View File

@ -4,7 +4,7 @@
* Author: Zero (glj0@outlook.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 在链表的节点 n0 之后插入节点 P */
void insert(ListNode *n0, ListNode *P) {

View File

@ -4,7 +4,7 @@
* Author: Zero (glj0@outlook.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 列表类简易实现 */
struct myList {

View File

@ -4,7 +4,7 @@
* Author: Guanngxu (446678850@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 二分查找(双闭区间) */
int binarySearch(int *nums, int len, int target) {

View File

@ -3,7 +3,7 @@
* Created Time: 2023-04-15
* Author: Gonglja (glj0@outlook.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 函数 */
int func() {

View File

@ -4,7 +4,7 @@
* Author: sjinzh (sjinzh@gmail.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 常数阶 */
int constant(int n) {

View File

@ -4,7 +4,7 @@
* Author: sjinzh (sjinzh@gmail.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 生成一个数组,元素为 { 1, 2, ..., n },顺序被打乱 */
int *randomNumbers(int n) {

View File

@ -4,7 +4,7 @@
* Author: Guanngxu (446678850@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 哈希表默认数组大小 */
# define HASH_MAP_DEFAULT_SIZE 100

View File

@ -4,7 +4,7 @@
* Author: Reanon (793584285@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
#define MAX_SIZE 5000

View File

@ -4,7 +4,7 @@
* Author: Gonglja (glj0@outlook.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 哈希表 */
struct hashTable {

View File

@ -4,7 +4,7 @@
* Author: Reanon (793584285@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 方法一:暴力枚举 */
int *twoSumBruteForce(int *nums, int numsSize, int target, int *returnSize) {

View File

@ -4,7 +4,7 @@
* Author: Guanngxu (446678850@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 线性查找(数组) */
int linearSearchArray(int *nums, int len, int target) {

View File

@ -4,7 +4,7 @@
* Author: Listening (https://github.com/L-Super)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 冒泡排序 */
void bubbleSort(int nums[], int size) {

View File

@ -4,7 +4,7 @@
* Author: Reanon (793584285@qq.com), Guanngxu (446678850@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 计数排序 */
// 简单实现,无法用于排序对象

View File

@ -4,7 +4,7 @@
* Author: Listening (https://github.com/L-Super)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 插入排序 */
void insertionSort(int nums[], int size) {

View File

@ -4,7 +4,7 @@
* Author: Guanngxu (446678850@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 合并左子数组和右子数组 */
// 左子数组区间 [left, mid]

View File

@ -4,7 +4,7 @@
* Author: Reanon (793584285@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 元素交换 */
void swap(int nums[], int i, int j) {

View File

@ -4,7 +4,7 @@
* Author: Reanon (793584285@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 获取元素 num 的第 k 位,其中 exp = 10^(k-1) */
int digit(int num, int exp) {

View File

@ -4,7 +4,7 @@
* Author: Gonglja (glj0@outlook.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 基于环形数组实现的双向队列 */
struct arrayDeque {

View File

@ -4,7 +4,7 @@
* Author: Zero (glj0@outlook.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 基于环形数组实现的队列 */
struct arrayQueue {

View File

@ -4,7 +4,7 @@
* Author: Zero (glj0@outlook.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
#define MAX_SIZE 5000

View File

@ -4,7 +4,7 @@
* Author: Gonglja (glj0@outlook.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 双向链表节点 */
struct doublyListNode {

View File

@ -4,7 +4,7 @@
* Author: Gonglja (glj0@outlook.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 基于链表实现的队列 */
struct linkedListQueue {

View File

@ -4,7 +4,7 @@
* Author: Zero (glj0@outlook.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 基于链表实现的栈 */
struct linkedListStack {

View File

@ -4,7 +4,7 @@
* Author: Reanon (793584285@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* AVL Tree */
struct aVLTree {

View File

@ -4,7 +4,7 @@
* Author: Reanon (793584285@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 二叉搜索树 */
struct binarySearchTree {

View File

@ -4,7 +4,7 @@
* Author: Reanon (793584285@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* Driver Code */
int main() {

View File

@ -4,7 +4,7 @@
* Author: Reanon (793584285@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 层序遍历 */
int *levelOrder(TreeNode *root, int *size) {

View File

@ -4,7 +4,7 @@
* Author: Reanon (793584285@qq.com)
*/
#include "../include/include.h"
#include "../utils/common.h"
/* 辅助数组,用于存储遍历序列 */
int *arr;

View File

@ -1,5 +0,0 @@
add_executable(include
include_test.c
include.h print_util.h
list_node.h tree_node.h
uthash.h)

View File

@ -0,0 +1,5 @@
add_executable(utils
common_test.c
common.h print_util.h
list_node.h tree_node.h
uthash.h)

View File

@ -1,5 +1,5 @@
/**
* File: include.h
* File: common.h
* Created Time: 2022-12-20
* Author: MolDuM (moldum@163.com)Reanon (793584285@qq.com)
*/

View File

@ -4,7 +4,7 @@
* Author: Reanon (793584285@qq.com)
*/
#include "include.h"
#include "common.h"
void testListNode() {
int nums[] = {2, 3, 5, 6, 7};

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 随机返回一个数组元素 */
int randomAccess(int *nums, int size) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 在链表的节点 n0 之后插入节点 P */
void insert(ListNode *n0, ListNode *P) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* Driver Code */
int main() {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 列表类简易实现 */
class MyList {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 回溯算法:全排列 I */
void backtrack(vector<int> &state, const vector<int> &choices, vector<bool> &selected, vector<vector<int>> &res) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 回溯算法:全排列 II */
void backtrack(vector<int> &state, const vector<int> &choices, vector<bool> &selected, vector<vector<int>> &res) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
vector<TreeNode *> res;

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
vector<TreeNode *> path;
vector<vector<TreeNode *>> res;

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
vector<TreeNode *> path;
vector<vector<TreeNode *>> res;

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 判断当前状态是否为解 */
bool isSolution(vector<TreeNode *> &state) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 二分查找(双闭区间) */
int binarySearch(vector<int> &nums, int target) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 函数 */
int func() {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 常数阶 */
int constant(int n) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 生成一个数组,元素为 { 1, 2, ..., n },顺序被打乱 */
vector<int> randomNumbers(int n) {

View File

@ -4,7 +4,7 @@
* Author: what-is-me (whatisme@outlook.jp), Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 基于邻接表实现的无向图类 */
class GraphAdjList {

View File

@ -4,7 +4,7 @@
* Author: what-is-me (whatisme@outlook.jp)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 基于邻接矩阵实现的无向图类 */
class GraphAdjMat {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
#include "./graph_adjacency_list.cpp"
/* 广度优先遍历 BFS */

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
#include "./graph_adjacency_list.cpp"
/* 深度优先遍历 DFS 辅助函数 */

View File

@ -4,7 +4,7 @@
* Author: msk397 (machangxinq@gmail.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 键值对 int->String */
struct Entry {

View File

@ -4,7 +4,7 @@
* Author: msk397 (machangxinq@gmail.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* Driver Code */
int main() {

View File

@ -4,7 +4,7 @@
* Author: LoneRanger(836253168@qq.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
void testPush(priority_queue<int> &heap, int val) {
heap.push(val); // 元素入堆

View File

@ -4,7 +4,7 @@
* Author: LoneRanger (836253168@qq.com), what-is-me (whatisme@outlook.jp)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 大顶堆 */
class MaxHeap {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 哈希查找(数组) */
int hashingSearchArray(unordered_map<int, int> map, int target) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 方法一:暴力枚举 */
vector<int> twoSumBruteForce(vector<int> &nums, int target) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 线性查找(数组) */
int linearSearchArray(vector<int> &nums, int target) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 冒泡排序 */
void bubbleSort(vector<int> &nums) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 桶排序 */
void bucketSort(vector<float> &nums) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 计数排序 */
// 简单实现,无法用于排序对象

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 插入排序 */
void insertionSort(vector<int> &nums) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 合并左子数组和右子数组 */
// 左子数组区间 [left, mid]

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 快速排序类 */
class QuickSort {

View File

@ -5,7 +5,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 获取元素 num 的第 k 位,其中 exp = 10^(k-1) */
int digit(int num, int exp) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 基于环形数组实现的双向队列 */
class ArrayDeque {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 基于环形数组实现的队列 */
class ArrayQueue {

View File

@ -4,7 +4,7 @@
* Author: qualifier1024 (2539244001@qq.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 基于数组实现的栈 */
class ArrayStack {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* Driver Code */
int main() {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 双向链表节点 */
struct DoublyListNode {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 基于链表实现的队列 */
class LinkedListQueue {

View File

@ -4,7 +4,7 @@
* Author: qualifier1024 (2539244001@qq.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 基于链表实现的栈 */
class LinkedListStack {

View File

@ -4,7 +4,7 @@
* Author: qualifier1024 (2539244001@qq.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* Driver Code */
int main() {

View File

@ -4,7 +4,7 @@
* Author: qualifier1024 (2539244001@qq.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* Driver Code */
int main() {

View File

@ -4,7 +4,7 @@
* Author: what-is-me (whatisme@outlook.jp)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* AVL 树 */
class AVLTree {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 二叉搜索树 */
class BinarySearchTree {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* Driver Code */
int main() {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
/* 层序遍历 */
vector<int> levelOrder(TreeNode *root) {

View File

@ -4,7 +4,7 @@
* Author: Krahets (krahets@163.com)
*/
#include "../include/include.hpp"
#include "../utils/common.hpp"
// 初始化列表,用于存储遍历序列
vector<int> vec;

View File

@ -1,4 +0,0 @@
add_executable(include
include.hpp PrintUtil.hpp
ListNode.hpp TreeNode.hpp
Vertex.hpp)

View File

@ -0,0 +1,4 @@
add_executable(utils
common.hpp print_utils.hpp
list_node.hpp tree_node.hpp
vertex.hpp)

View File

@ -1,5 +1,5 @@
/**
* File: PrintUtil.hpp
* File: common.hpp
* Created Time: 2021-12-19
* Author: Krahets (krahets@163.com)
*/
@ -20,9 +20,9 @@
#include <unordered_set>
#include <vector>
#include "ListNode.hpp"
#include "PrintUtil.hpp"
#include "TreeNode.hpp"
#include "Vertex.hpp"
#include "list_node.hpp"
#include "print_utils.hpp"
#include "tree_node.hpp"
#include "vertex.hpp"
using namespace std;

View File

@ -1,5 +1,5 @@
/**
* File: PrintUtil.hpp
* File: list_node.hpp
* Created Time: 2021-12-19
* Author: Krahets (krahets@163.com)
*/

View File

@ -1,13 +1,13 @@
/**
* File: PrintUtil.hpp
* File: print_utils.hpp
* Created Time: 2021-12-19
* Author: Krahets (krahets@163.com), msk397 (machangxinq@gmail.com), LoneRanger(836253168@qq.com)
*/
#pragma once
#include "ListNode.hpp"
#include "TreeNode.hpp"
#include "list_node.hpp"
#include "tree_node.hpp"
#include <climits>
#include <iostream>
#include <sstream>

View File

@ -1,5 +1,5 @@
/**
* File: PrintUtil.hpp
* File: tree_node.hpp
* Created Time: 2021-12-19
* Author: Krahets (krahets@163.com)
*/

View File

@ -1,5 +1,5 @@
/**
* File: PrintUtil.hpp
* File: vertex.hpp
* Created Time: 2023-03-02
* Author: Krahets (krahets@163.com)
*/

View File

@ -1,5 +1,5 @@
/**
* File: graph_adjacency_list.cs
* File: Vertex.cs
* Created Time: 2023-02-06
* Author: zjkung1123 (zjkung1123@gmail.com), krahets (krahets@163.com)
*/

View File

@ -1,5 +1,5 @@
/**
* File: ListNode
* File: list_node.dart
* Created Time: 2023-01-23
* Author: Jefferson (JeffersonHuang77@gmail.com)
*/

View File

@ -1,5 +1,5 @@
/**
* File: PrintUtil
* File: print_util.dart
* Created Time: 2023-01-23
* Author: Jefferson (JeffersonHuang77@gmail.com)
*/

View File

@ -6,7 +6,7 @@
package chapter_array_and_linkedlist;
import include.*;
import utils.*;
public class linked_list {
/* 在链表的节点 n0 之后插入节点 P */

View File

@ -6,7 +6,7 @@
package chapter_backtracking;
import include.*;
import utils.*;
import java.util.*;
public class preorder_traversal_i_compact {

View File

@ -6,7 +6,7 @@
package chapter_backtracking;
import include.*;
import utils.*;
import java.util.*;
public class preorder_traversal_ii_compact {

View File

@ -6,7 +6,7 @@
package chapter_backtracking;
import include.*;
import utils.*;
import java.util.*;
public class preorder_traversal_iii_compact {

View File

@ -6,7 +6,7 @@
package chapter_backtracking;
import include.*;
import utils.*;
import java.util.*;
public class preorder_traversal_iii_template {

View File

@ -6,7 +6,7 @@
package chapter_computational_complexity;
import include.*;
import utils.*;
import java.util.*;
public class space_complexity {

Some files were not shown because too many files have changed in this diff Show More