{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

cse2331-lec10

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

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

CSE 2331/5331 CSE 780: Design and Analysis of Algorithms Lecture 10: Binary Search Tree Data structure Operations

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

View Full Document
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?
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

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

View Full Document
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
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

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

View Full Document
CSE 2331/5331 Example 13 18 3 2 6 4 7 13 9 17 20
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

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

View Full Document
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
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• 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.

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

• 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.

Dana University of Pennsylvania ‘17, Course Hero Intern

• 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.

Jill Tulane University ‘16, Course Hero Intern