Join Raghavendra Dixit for an in-depth discussion in this video Finding smallest and largest values, part of Introduction to Data Structures & Algorithms in Java.
- [Instructor] Now let's find the smallest and largest…data values contained in a binary search tree.…So if we look at this example, can you find…which node contains the smallest value…and which one the largest?…Let's find the smallest one first.…All we need to do is to use the binary search tree property.…That is for any given node all values contained…in the left subtree are smaller,…and those in the right subtree are larger…than the value in that node.…So to find the smallest value, all we need to do…is start from the root and keep going to the left child…until we reach a node which does not…have a left child.…
All right?…And that node should contain the smallest data value.…So in this example, the smallest integer is 12.…And we can find the largest integer in the same way.…Keep going to the right child until we come to a note…which does not have a right child,…although it may have a left child, all right?…So this node contains the largest value…in the binary search tree.…And you can do it iteratively or recursively.…
Note: This course was created by Packt Publishing. We are pleased to host this training in our library.
- Why study data structures and algorithms?
- How to calculate the time complexity
- Using Big O notation
- Using basic sorting and search algorithms
- Searching elements in unordered arrays and ordered arrays
- Implementing a linked list in Java
- Implementing stacks using arrays
- Queues using arrays
- Binary search trees
- Representing heaps using arrays
Skill Level Intermediate
1. Introduction to Algorithms
2. Analysis of Algorithms
3. Basic Sorting and Search Algorithms
4. Linked Lists
5. Stacks and Queues
7. Binary Search Trees
8. More Sorting Algorithms
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.