Posts

Unit - V -Data Structure - Searching, Sorting & Hashing

Image
  UNIT- V -  Data Structure Searching Searching in a data structure is the process of finding  a specific element within a collection of items . The two primary methods are  linear search  (for unsorted data) and  binary search  (for sorted data).   1. Linear Search Linear search, also known as sequential search, checks each element in a data structure one by one, from start to finish, until the target is found. It is simple to implement and works on both sorted and unsorted lists, but is inefficient for large datasets due to a time complexity of O(n).    How it works: 1.       Start the program. 2.       Read the number of elements and store them in a list. 3.       Read the element to be searched. 4.       Compare the search element with each element of the list one by one. 5.       If a match...

Data Structure - Binary Tree

Image
  Binary Tree  Binary Tree  is a non-linear and hierarchical   data structure where each node has  at most two children  referred to as the left child and the right child.  The topmost node in a binary tree is called the root, and the bottom-most nodes(having no children) are called leaves. Representation of Binary Tree Each node in a Binary Tree has three parts: ·          Data ·          Pointer to the left child ·          Pointer to the right child   Terminologies in Binary Tree ·          Parent Node : A node that is the  direct ancestor  of a node(its child node). ·          Child Node : A node that is the  direct descendant  of another node (its parent). ·        ...