Skip to main content

Posts

Showing posts with the label min

Minimum and Maximum element in Binary Search Tree

Minimum and Maximum elements of a Binary Search Tree can be found very easily. If we see the insertion method of a Binary Search Tree we see that if the new element is greater than the current node data then we move to its right subtree ,Similarly if the new Element is less than the current node data we move to its left subtree. Hence we can easily infer that the smallest element of the Binary Search Tree must be the leftmost node of the tree. Similarly we can say also infer that largest element should be the rightmost node of the tree. The following image makes the above statement more clear. In the above figure we see that 1 is the smallest element of the tree which is also the leftmost node of the tree and 14 is the largest element of the tree is rightmost node of the binary tree. To know more about binary search tree click  here . To see more operations of binary search tree Visit the following Links Binary Search tree in C++ Binary Search tree in Python ...

Binary search tree in cpp

Binary Search Tree is a rooted binary tree. Its subtrees have certain properties. Each element of the binary tree is a node that has mainly 3 fields, data or element field left link  right link For each node in a binary search tree, the data of the left node is less than the parent node and data of the right node is greater than the parent node. It can be seen in the image above that the data in the left child node is less than the data of the parent node and data of the right child node is greater than the parent node. There are a lot of advantages of using the binary search tree data structure, they are related to searching, sorting, using them as priority queues, etc. To know more about binary search tree click  here . The following program has the following operations implemented isEmpty() : method that checks if the tree is empty. getRoot() :  method that returns the root element of the binary search tree. insert() : Insertion in ...

Linked List in Cpp

Linked list is a simple linear data structure formed by collection of data elements called nodes. Each node consists of a data element and link field. There is a head node that points to the starting of the linked list. this diagram shows a simple representation of the linked list. Linked list can be used to implement stacks, queues, list, associative arrays, etc.  Unlike arrays linked lists are not stored in contagious memory locations rather the are stored at any empty place in memory and the address of the next node is stored in the link field. Also you don't need to declare the size of the linked list at the time of initialization you can dynamically keep adding elements to the linked list. Click for complete information on  Linked List  The following implementation of the linked list has the following methods implemented : 1. isEmpty() : method returns true if the list is empty 2. getHead() : returns head node 3. addToSt...

Linked List in Java

Linked list is a simple linear data structure formed by collection of data elements called nodes. Each node consists of a data element and link field. There is a head node that points to the starting of the linked list. this diagram shows a simple representation of the linked list. Linked list can be used to implement stacks, queues, list, associative arrays, etc.  Unlike arrays linked lists are not stored in contagious memory locations rather the are stored at any empty place in memory and the address of the next node is stored in the link field. Also you don't need to declare the size of the linked list at the time of initialization you can dynamically keep adding elements to the linked list. Click for complete information on  Linked List  The following implementation of the linked list has the following methods implemented : isEmpty() : method returns true if the list is empty addToEnd() : method to add a node at the end di...

Linked List in python

Linked list is a simple linear data structure formed by collection of data elements called nodes. Each node consists of a data element and link field. There is a head node that points to the starting of the linked list. this diagram shows a simple representation of the linked list. Linked list can be used to implement stacks, queues, list, associative arrays, etc.  Unlike arrays linked lists are not stored in contagious memory locations rather the are stored at any empty place in memory and the address of the next node is stored in the link field. Also you don't need to declare the size of the linked list at the time of initialization you can dynamically keep adding elements to the linked list. Click for complete information on Linked List  The following implementation of the linked list has the following methods implemented : isEmpty() : Returns true if the Linked List is empty. addToStart() : Adds elements at the start of the linked Li...