1 / 9

CSE 3358 Note Set 15

CSE 3358 Note Set 15. Data Structures and Algorithms. Multiway Search Tree of Order m. AKA: m-way search tree Properties Each node has m children and m – 1 keys Keys in each node are in ascending order Keys in first i children are smaller than the i-th key

ferrol
Download Presentation

CSE 3358 Note Set 15

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CSE 3358 Note Set 15 Data Structures and Algorithms

  2. Multiway Search Tree of Order m • AKA: m-way search tree • Properties • Each node has m children and m – 1 keys • Keys in each node are in ascending order • Keys in first i children are smaller than the i-th key • The keys in the last m – i children are larger than the i-th key

  3. Disk Access • Not all data needed is stored in main memory during execution of a program • Think Database Systems for example • Any access to secondary storage is much (much, much, much) slower than access to main memory • Makes big-oh useless to compare one algorithms

  4. Disk Access • Disk Access – based on block i/o • On request • position has to be located on disk • Read/write head has to be moved to that location • Data has to be read or written

  5. B-Tree • Used with algorithms that access secondary storage • Each node • can be any size, but makes sense to make it the same size as a block on the HD • Contains a certain number of keys • Number of keys depends on the size of a key and size of a block (do the math)

  6. B-Tree of order m • B-Tree of order M is a m-way search tree with the following properties: • The root has at least two subtrees unless it is a leaf • Each nonroot and each nonleaf node holds k – 1 keys and k pointers to subtrees where ceil(m/2) <= k <= m • Each leaf node holds k – 1 keys where cei(m/2) <= k <= m. • All leaves are on the same level. 5 19 27 45 63 m = 6

  7. Basic Node Idea template <class T, int M> class BTreeNode { public: BTreeNode(); //Other constructors as needed private: bool leaf; intkeyTally; //# of keys currently stored in node T keys[M-1]; BTreeNode* pointers[M]; };

  8. Inserting into a B-Tree • The possibilities • A key is placed in a leaf that still has some room • The leaf in which a key should be placed is full. • New leaf is created. • ½ keys stay in original leaf, ½ go to new leaf • Middle key is moved to the parent • (Same thing happens for non-leaf nodes) • Root is full • old root is split • middle key to new root • other keys split between old root and its new sibling

  9. ?

More Related