2620001 data structures n.
Download
Skip this Video
Download Presentation
2620001 Data Structures

Loading in 2 Seconds...

play fullscreen
1 / 18

2620001 Data Structures - PowerPoint PPT Presentation


  • 76 Views
  • Uploaded on

2620001 Data Structures. Search Trees. B+ - Tree Structure. A B+ - Tree is in the form of a balanced tree in which every path from the root of the tree to a leaf of the tree is the same length. Each nonleaf node in the tree has between [n/2] and n children, where n is fixed.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about '2620001 Data Structures' - lowri


Download Now 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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
b tree structure
B+ - Tree Structure
  • A B+ - Tree is in the form of a balanced tree in which every path from the root of the tree to a leaf of the tree is the same length.
  • Each nonleaf node in the tree has between [n/2] and n children, where n is fixed.
  • B+ - Trees are good for searches, but cause some overhead issues in wasted space.
b trees summary
B+ Trees: Summary
  • Searching:
    • logd(n) – Where d is the order, and n is the number of entries
  • Insertion:
    • Find the leaf to insert into
    • If full, split the node, and adjust index accordingly
    • Similar cost as searching
  • Deletion
    • Find the leaf node
    • Delete
    • May not remain half-full; must adjust the index accordingly
standard tries
Standard Tries
  • The standard trie for a set of strings S is an ordered tree such that:
    • Each node but the root is labeled with a character
    • The children of a node are alphabetically ordered
    • The paths from the external nodes to the root yield the strings of S
  • Example: standard trie for the set of strings

S = { bear, bell, bid, bull, buy, sell, stock, stop }

trie suffix tree
Trie / Suffix Tree
  • A tree representing a set of strings.

c

a

{

aeef

ad

bbfe

bbfg

c }

b

e

b

d

e

f

c

f

e

g

threaded binary trees
Threaded Binary Trees
  • Binary trees have a lot of wasted space: the leaf nodes each have 2 null pointers
  • We can use these pointers to help us in inorder traversals
  • We have the pointers reference the next node in an inorder traversal; called threads
  • We need to know if a pointer is an actual link or a thread, so we keep a boolean for each pointer
threaded tree code
Threaded Tree Code
  • Example code:

class Node {

Node left, right;

boolean leftThread, rightThread;

}

threaded binary tree traversal
Threaded Binary Tree Traversal
  • We start at the leftmost node in the tree, print it, and follow its right thread
  • If we follow a thread to the right, we output the node and continue to its right
  • If we follow a link to the right, we go to the leftmost node, print it, and continue
threaded tree traversal
Threaded Tree Traversal

Output

1

3

6

8

3

1

5

7

11

9

13

Follow thread to right, print node

threaded tree traversal1
Threaded Tree Traversal

Output

1

3

5

6

8

3

1

5

7

11

9

13

Follow link to right, go to leftmost node and print

threaded tree traversal2
Threaded Tree Traversal

Output

1

3

5

6

6

8

3

1

5

7

11

9

13

Follow thread to right, print node

threaded tree traversal3
Threaded Tree Traversal

Output

1

3

5

6

7

6

8

3

1

5

7

11

9

13

Follow link to right, go to leftmost node and print

threaded tree traversal4
Threaded Tree Traversal

Output

1

3

5

6

7

8

6

8

3

1

5

7

11

9

13

Follow thread to right, print node

threaded tree traversal5
Threaded Tree Traversal

Output

1

3

5

6

7

8

9

6

8

3

1

5

7

11

9

13

Follow link to right, go to leftmost node and print

threaded tree traversal6
Threaded Tree Traversal

Output

1

3

5

6

7

8

9

11

6

8

3

1

5

7

11

9

13

Follow thread to right, print node

threaded tree traversal7
Threaded Tree Traversal

Output

1

3

5

6

7

8

9

11

13

6

8

3

1

5

7

11

9

13

Follow link to right, go to leftmost node and print