Posts

Showing posts from June, 2023

Data Structures(Applications for Binary trees)

Application of Binary Trees: ·         Search algorithms:  Binary search algorithms use the structure of binary trees to efficiently search for a specific element. The search can be performed in O(log n) time complexity, where n is the number of nodes in the tree. ·         Sorting algorithms:  Binary trees can be used to implement efficient sorting algorithms, such as binary search tree sort and heap sort. ·         Database systems:  Binary trees can be used to store data in a database system, with each node representing a record. This allows for efficient search operations and enables the database system to handle large amounts of data. ·         File systems:  Binary trees can be used to implement file systems, where each node represents a directory or file. This allows for efficient navigation and searching of the fi...

Data Structures(Binary Search Tree)

Image
Binary Search Tree In a binary tree, every node can have a maximum of two children but there is no need to maintain the order of nodes basing on their values. In a binary tree, the elements are arranged in the order they arrive at the tree from top to bottom and left to right. A binary tree has the following time complexities... Search Operation  - O(n) Insertion Operation  - O(1) Deletion Operation  - O(n) To enhance the performance of binary tree, we use a special type of binary tree known as  Binary Search Tree . Binary search tree mainly focuses on the search operation in a binary tree. Binary search tree can be defined as follows... Binary Search Tree is a binary tree in which every node contains only smaller values in its left subtree and only larger values in its right subtree. In a binary search tree, all the nodes in the left subtree of any node contains smaller values and all the nodes in the right subtree of any node c...

Data Structures(Binary tree Representation)

Image
  Binary Tree Representations A binary tree data structure is represented using two methods. Those methods are as follows... Array Representation Linked List Representation Consider the following binary tree... 1. Array Representation of Binary Tree In array representation of a binary tree, we use one-dimensional array (1-D Array) to represent a binary tree. Consider the above example of a binary tree and it is represented as follows... To represent a binary tree of depth  'n'  using array representation, we need one dimensional array with a maximum size of  2n + 1 . 2. Linked List Representation of Binary Tree We use a double linked list to represent a binary tree. In a double linked list, every node consists of three fields. First field for storing left child address, second for storing actual data and third for storing right child address. In this linked list representation, a node has the following structure... The above e...

Data structures(indexed Sequential Search)

Image
Indexed Sequential Search In this searching method, first of all, an index file is created, that contains some specific group or division of required record when the index is obtained, then the partial indexing takes less time cause it is located in a specified group. Characteristics of Indexed Sequential Search: ·         In Indexed Sequential Search a sorted index is set aside in addition to the array. ·         Each element in the index points to a block of elements in the array or another expanded index. ·         The index is searched 1st then the array and guides the search in the array. Note:  Indexed Sequential Search actually does the indexing multiple time, like creating the index of an index.    Explanation by diagram “Indexed Sequential Search”: void indexedSequentialSearch(int arr[], int n, int k) {     int G...