{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cse2331-lec10 - CSE 780 Design and Analysis of Algorithms...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 2331/5331 CSE 780: Design and Analysis of Algorithms Lecture 10: Binary Search Tree Data structure Operations
Image of page 1

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSE 2331/5331 Set Operations n Maximum n Extract-Max n Insert n Increase-key n Search n Delete n Successor n Predecessor We can use priority queue (implemented by heap) Not efficient with heap! Linked list? Array?
Image of page 2
CSE 2331/5331 Search Tree n Support all of previous operations n Time proportional to tree height n Can be used to implement priority queues n Different types of search trees n Binary search tree, red-black trees, etc
Image of page 3

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSE 2331/5331 Binary Search Tree n First, it is a binary tree n Represented by a linked data structure n Each node contains at least fields: n Key n Left n Right n Parent Nil if does not exists
Image of page 4
CSE 2331/5331 Binary Search Tree cont. n Secondly, the binary-search-tree property n For any node x , Key[ y ] Key[ x ] if y in left subtree of x Key[ x ] Key[ y ] if y in right subtree of x
Image of page 5

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSE 2331/5331 Example 13 18 3 2 6 4 7 13 9 17 20
Image of page 6
CSE 2331/5331 Properties n Not unique for the same set of elements n Minimum n Does it have to be a leaf ? n Maximum
Image of page 7

Info icon This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
CSE 2331/5331 Query A Tree n Tree-search ( x, k ) n Given a node x and a key k , returns a node y in the subtree rooted at x if y .key = k if exists, Nil otherwise Tree-search ( x, k ) if x = Nil or k = x .key then return x if k < x .key
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern