首页 > 其他分享 >CSCI-1200 Simplified B+ Trees

CSCI-1200 Simplified B+ Trees

时间:2023-03-27 18:22:06浏览次数:41  
标签:node insert CSCI tree 1200 will Simplified nodes root

CSCI-1200 Data Structures — Spring 2023
Homework 8 — Simplified B+ Trees
In this assignment we will be implementing a partial and modified version of B+ trees. As a result, online
resources may not use the same terminology or may describe implementation details that are not relevant
to our HW8 implementation. You should read the entire assignment before beginning your work. You
should also make sure you understand the basic concepts discussed at the end of Lecture 17. It is highly
recommended that before you begin coding, you practice constructing a couple of trees (using b = 3, b = 4)
by hand and then checking your work with this online visualization tool:
https://www.cs.usfca.edu/~galles/visualization/BPlusTree.html
The bulk of the assignment will focus on proper insertion in a B+ tree, which is described on the next page.
Implementation Details
In this assignment we will assume that the keys we insert are unique, i.e. for a particular B+ tree, we will
never call insert(3); insert(3);. We will also assume that b > 2 in all tests. You will find it beneficial to
borrow code from our partial implementation of the ds set class. We will not implement iterators, so find()
should instead return a pointer to a BPlusTreeNode. If the tree is empty, this will be a NULL pointer,
otherwise this will be the leaf node where the key is/would be. The print functions only need to work with
types/classes that already work with operator<<, and PrintSideways makes its split at b/2 children. You
must implement all of the functions required to make hw8 test.cpp compile and run correctly.
Hints
Unless the tree is empty, find() will always return a pointer to a node in the tree. You do not need to store
NULL pointers. In the middle of an insertion, it is okay to let your nodes hold too many keys or children as
long as you fix it before the insertion and splits are finished. Since this is a tree, some things will be more
“natural” to do with recursion.
Submission
While you are encouraged to write your own test functions, we will not be looking at them. You only need
to submit a README.txt and BPlusTree.h file. Dr. Memory will be used on this assignment and you will
be penalized for leaks and memory errors in your solution. If you get at least 6 points between test cases
4, 5, and 6 by the end of Wednesday, you can submit on Friday without being charged a late day. Please
remember that all submissions are still due by the end of Saturday.
Extra Credit
With the way print BFS() is currently expected to output, it is not possible to tell which nodes are children
of a particular node. Assuming that each key is short (i.e. no more than 2 characters wide), implement a
function, print BFS pretty() that still uses a BFS ordering and a vertical layout like print BFS(), but that
has appropriate spacing so the structure of the tree is apparent. There are several possible ways to handle
this, so you may choose whatever design you think is reasonable. Make sure to leave a note in your README
if you implement the extra credit.
Insertion
b
a b c
a b
b
a b c
(1)
(2)
(3)
(4)
Starting from an empty tree, with b = 3 in this example we do
the following:
(1) insert(b); creates a root node with “b” in it.
(2) insert(a); adds “a” to the root node
(3) insert(c); adds “c” to the root node, which makes it too
full.
(4) The root node splits into two nodes, one with “a” and one
with “b”, and “c”. A new parent is created, with the first
value from the new right-hand node (“b”) placed in it. A
node split should create two new nodes and put half of the
orginal node’s keys into each of the new nodes. Whenever
there are an odd number of keys in a node that needs to be
split, the “extra” key will go to the right-hand node.
(1) This example starts with one possible
tree with b = 3 and the keys “a”-“f”.
(2) insert(ant) causes a leaf to become
too full. “ant” comes after “a”
according to string’s operator<.
(3) The leaf containing “a”, “ant”, “b” is
split into two nodes, but this makes
the parent too full.
(4) We split the overfull node, creating
a new parent which is now the root.
Since this split a non-leaf node, we do
not copy the middle key of “a,c,e” into
the new left/right nodes - “c” only
appears in the newly created root. A
split at a leaf always has the potential
to cause more splits all the way up to
splitting the root.
WX:codehelp mailto: [email protected]

标签:node,insert,CSCI,tree,1200,will,Simplified,nodes,root
From: https://www.cnblogs.com/nytalt/p/17262467.html

相关文章

  • Haskell CSCI3136 Ripple Effect
    HaskellCSCI3136RippleEffectProblemDescriptionRippleEffectorHakyuuisalogicpuzzlesomewhatsimilartoSudoku.Thepuzzleconsistsofarectangulargri......
  • mpi转以太网连接300PLC无需编程与1200PLC数据交换
    300PLC转以太网无需编程300PLC通过NetDevice与1200PLC数据交换应用概述:兴达易控MPI转以太网模块MPI-ETH-XD1.0PLUS通讯模块实现PLC无需编程通过简单的命令配置到模块,实现......
  • 西门子300PLC转以太网无需编程实现与1200PLC转以太网数据交换
    西门子300PLC转以太网无需编程实现与1200PLC转以太网数据通信本文介绍利用兴达易控生产的PLC转以太网模块(MPI-ETH-XD1.0Plus)实现1200/1500PLC与300(CPU315-2DP)PLC无需用......
  • CF1736B 1200 *
    题意解析解析:每个a[i]是由b[i]和b[i+1]取最大公因数得出,所以对于每个b[j]来说应该既是a[j]的倍数,又是a[j-1]的倍数。现实在取的时候,可以取b[j]=lcm(a[j-1],a[j])。然......
  • RS485 MODBUS转PROFINET网关案例 | 超声波明渠流量计接入到PLC1200 PROFINE
    本案例介绍的是用北京小疆智控(北京)技术有限公司生产的GW-PN5003型RS485转PROFINET网关将超声波明渠流量计接入西门子PLC1200PROFINET网络的使用方法:  1、首先创建新......
  • CF522A 1200 *
    题意Polycarp在他的微博上发布了一张有趣的照片。他的很多朋友就开始在微博上转发这张图片,这个事情可以被一个字符串描述:name1repostedname2,意思是说name1这个人转发了n......
  • CF729B 1200
    题意解析我写的朴素的二维前缀和,这样比较麻烦可以这样,f1[i][j]代表当前行第一个到第j个的前缀和f1[i][j]=f1[i][j-1]+a[i][j]f2[i][j]代表当前列第一个到第i个的前......
  • csci 体系结构设计怎么写
    ComputerSoftwareConfigurationItem 计算机软件配置项  参考文献:计算机软件配置项csci-百度文库(baidu.com)说人话:软件产品的各个组成部分,细分到xx模块 ......
  • CF1200E Compress Words
    洛谷题目传送门分析模拟过程是先是前两个单词合并,合并之后的句子再接着和第三个单词合并这样子所以过程中肯定是要开个\(ans\)串不断去进行合并预处理和答案累加合并......
  • CF489B 1200 *
    题意解析如果对于一个a数列中的一个最小的数a[x],它可能和多个在b数列的数相匹配,显然,我需要先试试b数列中最小的一个b[y],如果可行,那么赶紧配对,再试试a数列中第......