golang sorting algorithm and data construction.

data-structures-questions

算法和程序结构是我们学习编程的基础,但是很多的时候,我们很多都是只是在应用,而没有深入的去研究这些,所以自己也在不断的思考和探索,然后分析,学习,总结自己学习的过程,希望可以和大家一起学习和交流下算法!

目录

data-structures-questions

觉得此文章不错,支持我的话可以给我star ,! 如果有问题可以加我的微信Sen0676,也可以加入我们的交流群一起交流技术!

License

This is free software distributed under the terms of the MIT license

Comments
  • 10.Redis事物的了解CheckAndSet操作实现乐观锁 - 回答中 涉及

    10.Redis事物的了解CheckAndSet操作实现乐观锁 - 回答中 涉及"回滚" 部分描述有误?

    回答中说到 Redis 会进行回滚??官方文档上说的是 Redis 是不支持回滚的。如果在事务中的某条命令发生错误,Redis 会继续把剩下的命令都执行完,保证原子性,但是,Redis 的数据不会回到事务执行之前的了。

    另外回答中还说到一点,把 DISCARD 看作关系数据库中的 ROLLBACK,似乎也不对吧....... 关系型数据库(MySQL)中事务回滚靠的不是回滚日志么.... 也就是说 INSERT 了一条数据,回滚日志中会有一条 DELETE 命令。但是 DISCARD 是刷新事务队列,退出事务。并不能 ROLLBACK 吧。。。。。。。。。。。。

    如果我疑问的部分有什么不对,欢迎大家指正... 冒昧了..

  • 关于 defer 函数的使用,输出结果是否有问题

    关于 defer 函数的使用,输出结果是否有问题

    Go中的defer函数使用下面的两种情况下结果是什么

    Go中的defer函数使用下面的两种情况下结果是什么 我们看看下面两种defer函数的返回的是什么:

    	a := 1
    	defer fmt.Println("the value of a1:",a)
    	a++
    
    	defer func() {
    		fmt.Println("the value of a2:",a)
    	}()
    

    运行:

    the value of a1: 1
    the value of a1: 2
    

    这里运行结果是否写错了? 运行环境 go 1.16 mac

    the value of a2: 2
    the value of a1: 1
    
  • 关于zset的疑问

    关于zset的疑问

    这部分内容是不是可以考虑修正下?我看源码注释是说的使用了跳表和hash表,其编码是使用了压缩链表或跳表

    https://github.com/KeKe-Li/data-structures-questions/blob/master/src/chapter05/golang.01.md#Redis%E6%9C%89%E5%BA%8F%E9%9B%86%E5%90%88zset%E5%BA%95%E5%B1%82%E6%80%8E%E4%B9%88%E5%AE%9E%E7%8E%B0%E7%9A%84

    参考链接:

    https://github.com/redis/redis/blob/unstable/src/t_zset.c#L39 http://redisbook.com/preview/object/sorted_set.html

  • question

    question

    image

    1. go defer 使用 f2() 和 f3() 貌似一样?
    f2: defer 是在 t 赋值给 r 之后执行的,而 defer 延迟函数只改变了 t 的值,r 不变。正确答案 5。
    
    f3: 这里将 r 作为参数传入了 defer 表达式。故 func (r int) 中的 r 非 func f() (r int) 中的 r,只是参数命名相同而已。正确答案 1。
    

    推测是 f2() 例子不小心贴错?还望得到回复,谢谢。

  • 提问

    提问

    https://github.com/KeKe-Li/data-structures-questions/blob/master/src/chapter05/golang.01.md

    501 line

    另一种情况是P所分配的任务G很快就执行完了(分配不均),这就导致了这个处理器P很忙,但是其他的P还有任务,此时如果global runqueue没有任务G了,那么P不得不从其他的P里拿一些G来执行。

    "这就导致了这个处理器P很忙",这里指的是 P 已经将 G 执行完成了,所以是忙还是闲,还望得到您的回复,谢谢

  • Go 默认stack大小2KB吧?

    Go 默认stack大小2KB吧?

    分块式的栈是最初Go语言组织栈的方式。当创建一个goroutine的时候,它会分配一个8KB的内存空间来给goroutine的栈使用。我们可能会考虑当这8KB的栈空间被用完的时候该怎么办?

    Go默认stack大小2KB吧,Go 源代码如下:

    // The minimum size of stack used by Go code _StackMin = 2048

    if newg == nil { newg = malg(_StackMin) casgstatus(newg, _Gidle, _Gdead) allgadd(newg) // publishes with a g->status of Gdead so GC scanner doesn't look at uninitialized stack. }

  • 有关 TIME-WAIT 含义描述的疑问

    有关 TIME-WAIT 含义描述的疑问

    作者大大你好,请问您在网络问题的第 3 题中关于 TIME-WAIT 含义的描述替换为以下描述是否更加无异议?

    原:客户端收到服务端的FIN包,并立即发出ACK包做最后的确认,在此之后的2MSL时间称为TIME_WAIT状态。

    现:主动请求关闭连接的那一端收到被动关闭连接的另一端发送来的FIN包,并立即发出ACK包做最后的确认,在此之后的 2 MSL 时间称为 TIME-WAIT 状态。

The simplest sorting algorithm that sorts in quadratic time
The simplest sorting algorithm that sorts in quadratic time

Simplest sort Showcases the simplest sorting algorithm that works in quadratic time. From here. The pseudocode for this algo can be seen below (sorts

Oct 14, 2022
Smartsort - A smart sorting algorithm for Go to sort filename containing digits that is not zero padded

smartsort A smart sorting algorithm for Go to sort filename containing digits th

Mar 26, 2022
A radix sorting library for Go (golang)

zermelo A radix sorting library for Go. Trade memory for speed! import "github.com/shawnsmithdev/zermelo" func foo(large []uint64) zermelo.Sort(l

Jul 30, 2022
Data structure and algorithm library for go, designed to provide functions similar to C++ STL

GoSTL English | 简体中文 Introduction GoSTL is a data structure and algorithm library for go, designed to provide functions similar to C++ STL, but more p

Dec 26, 2022
Multi-String Pattern Matching Algorithm Using TrieHashNode

Multi-String Pattern Matching algorithm. This implementation is inspired from Aho-Corasick algorithm Getting Started modelA = mspm.NewModel("mspm_mode

Dec 9, 2022
A Go implementation of the 64-bit xxHash algorithm (XXH64)

xxhash xxhash is a Go implementation of the 64-bit xxHash algorithm, XXH64. This is a high-quality hashing algorithm that is much faster than anything

Dec 22, 2022
Implementation of Boyer-Moore fast string search algorithm in Go

boyermoore Implementation of Boyer-Moore fast string search algorithm in Go

Oct 7, 2022
A Go implementation of the core algorithm in paper

Boolean Expression Indexer Go library A Go implementation of the core algorithm in paper <Indexing Boolean Expression>, which already supports the fol

Dec 26, 2022
记录算法学习和LeetCode、LintCode、codewars的学习路程。A record of algorithm learning.

Problem List Leetcode、LintCode、Codewars Algorithm problem solution written by golang. LeetCode id Name(Github) Name(Gitee) 00001 TwoSum TwoSum 00003 L

Nov 3, 2021
Randomly generated tile maps using Oskar Stålberg's wave function collapse algorithm
Randomly generated tile maps using Oskar Stålberg's wave function collapse algorithm

go-wfc Procedurally-generated tile maps using wave function collapse. Demos Live demo (wasm): https://zfedoran.github.io/go-wfc-example/ Live algorith

Dec 26, 2022
Graphoscope: a solution to access multiple independent data sources from a common UI and show data relations as a graph
Graphoscope: a solution to access multiple independent data sources from a common UI and show data relations as a graph

Graphoscope A solution to access multiple independent data sources from a common UI and show data relations as a graph: Contains a list of by default

May 26, 2022
Gota: DataFrames and data wrangling in Go (Golang)

Gota: DataFrames, Series and Data Wrangling for Go This is an implementation of DataFrames, Series and data wrangling methods for the Go programming l

Jan 6, 2023
low level data type and utils in Golang.

low low level data type and utils in Golang. A stable low level function set is the basis of a robust architecture. It focuses on stability and requir

Dec 24, 2022
Algorithms and Data Structures Solved in Golang

Algorithms and Data Structures Solved in Golang Hi! I'm Bruno Melo and this repository contains a lot challenges solved on many plataforms using go as

Oct 20, 2022
Some data structures and algorithms using golang

Some data structures and algorithms using golang

Aug 13, 2022
Tutorial code for my video Learn to Use Basic Data Structures - Slices, Structs and Maps in Golang

Learn to Use Basic Data Structures - Slices, Structs and Maps in Golang Read text from a file and split into words. Introduction to slices / lists. Co

Jan 26, 2022
Dasel - Select, put and delete data from JSON, TOML, YAML, XML and CSV files with a single tool.
Dasel - Select, put and delete data from JSON, TOML, YAML, XML and CSV files with a single tool.

Select, put and delete data from JSON, TOML, YAML, XML and CSV files with a single tool. Supports conversion between formats and can be used as a Go package.

Jan 1, 2023
A simple Set data structure implementation in Go (Golang) using LinkedHashMap.

Set Set is a simple Set data structure implementation in Go (Golang) using LinkedHashMap. This library allow you to get a set of int64 or string witho

Sep 26, 2022
Trie data structure implementation in Golang 🌳

Gotri Gotri is an Unicode character based Trie/prefix tree implementation in Go, with the suggestion/auto-complete feature for character searching. Si

Jun 17, 2022