Giter VIP home page Giter VIP logo

b-plus-tree's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

b-plus-tree's Issues

IndexOutOfBoundsException in delete()

I think the delete() implementation might need to be improved. Please see the following failed test:

	@Test
	public void testDelete() throws Exception
	{
		BPlusTree<String,String> t = new BPlusTree<String,String>(4);
		
		t.insert("1", "1");
		t.insert("2", "2");
		t.insert("3", "3");
		t.insert("4", "4");
		
		t.delete("3"); // FIX breaks the tree invariants
		
		t.delete("4"); // throws an exception
	}

这个代码,删除中间值没问题,如果删除的是节点的边界值,会有问题

这个代码,删除中间值没问题,如果删除的是节点的边界值,会有问题,

插入 [0 ,30]
{[16]}
{[4, 8, 12], [20, 24, 28]}
{[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]}, {[16, 17, 18, 19], [20, 21, 22, 23], [24, 25, 26, 27], [28, 29, 30]}

删除24
{[16]}
{[4, 8, 12], [20, 24, 28]}
{[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]}, {[16, 17, 18, 19], [20, 21, 22, 23], [25, 26, 27], [28, 29, 30]}

删除25
{[16]}
{[4, 8, 12], [20, 24, 28]}
{[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]}, {[16, 17, 18, 19], [20, 21, 22, 23, 26, 27], [26, 27], [28, 29, 30]}

删除26
{[16]}
{[4, 8, 12], [20, 24, 26, 28]}
{[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]}, {[16, 17, 18, 19], [20, 21, 22, 23], [27], [26, 27, 27], [28, 29, 30]}

实际26还在,还能查出来,主要是因为删除叶子节点最左边(分界点),没有更新父节点对应的数据

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.