示例#1
0
文件: 2sum.go 项目: nveeser/peyta.com
func do2Sum(file string) {
	nums := readnums(file)

	buckets, tableSize := hashing.CountBuckets(nums)

	log.Printf("Buckets: %d", buckets)
	c := float32(len(nums)) / float32(buckets)
	log.Printf("Collisions: %f", c)
	a := float32(buckets) / float32(tableSize)
	log.Printf("Alpha: %f", a)

	distinct := hashing.SpecialSums(nums, -10000, 10000)
	log.Printf("Distinct: %d", distinct)
}
示例#2
0
文件: 2sum.go 项目: nveeser/peyta.com
func main() {
	{
		nums := readnums("src/project6/2sum.txt")
		distinct := hashing.SpecialSums(nums, -10000, 10000)
		log.Printf("Distinct: %d", distinct)
	}
	{
		nums := readnums("src/project6/Median.txt")

		var total int64
		m := &myheap.Median{}
		for _, n := range nums {
			m.Add(n)
			//log.Printf("Added %d Median: %d", n, m.Value())
			total += m.Value()
		}
		log.Printf("Total: %d", total%10000)
	}
}