Se ha denunciado esta presentación.
Se está descargando tu SlideShare. ×
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Anuncio
Próximo SlideShare
Binary tree
Binary tree
Cargando en…3
×

Eche un vistazo a continuación

1 de 11 Anuncio

Más Contenido Relacionado

Más reciente (20)

Anuncio

binary search tree

  1. 1. Binary Search tree (BST) Prepared by: Lavin m.saeed Dec.2022
  2. 2. 1 2 3 4 5 Out line: What is tree & (BST) ? Advantages of Binary search tree: Materials required: creating a binary search tree: Runtime: Basic Operations: Practice.
  3. 3. What is tree & (BST) ? A binary search tree follows some order to arrange the elements. In a Binary search tree, the value of left node must be smaller than the parent node, and the value of right node must be greater than the parent node. This rule is applied recursively to the left and right subtrees of the root.
  4. 4. As compared to array and linked lists, insertion and deletion operations are faster in BST. Searching an element in the Binary search tree is easy as we always have a hint that which subtree has the desired element. Advantages of Binary search tree:
  5. 5. keys leaf parent child Level 0 Level 1 Level 2 subtree Materials required:
  6. 6. creating a binary search tree: • First, we have to insert first element into the tree as the root of the tree. • Then, read the next element; if it is smaller than the root node, insert it as the root of the left subtree, and move to the next element. • Otherwise, if the element is larger than the root node, then insert it as the root of the right subtree. • We apply the same rule for all other nodes.
  7. 7. Runtime: • Best case: o(1). • Average case: o(log n). • Worst case: o(n). • Time complexity: o(1).
  8. 8. Basic Operations: Search Insert Delete Searches an element in a tree. Inserts an element in a tree. delete an element in a tree.
  9. 9. Practice: • Create (BST) by using this number: (45, 15, 79, 90, 10, 55, 12, 20, 50) • And using insert & search & delete operation:
  10. 10. Thanks…
  11. 11. Reference: • https://www.javatpoint.com/binary-search-tree • https://www.freecodecamp.org/news/binary-search-trees • https://www.freshbooks.com • https://www.dbs.com

×