Algo Inisa
Algo Inisa
● Fourth pass:
● Similarly, for fourth position traverse the
rest of the array and find the fourth least
element in the array
● As 25 is the 4th lowest value hence, it will
place at the fourth position.
Bubble Sort – simplest sorting algorithm that
works by repeatedly swapping the adjacent
elements if they are in the wrong order. This
algorithm is not suitable for large data sets as its
average and worst-case time complexity is quite
high.
● Second Pass:
● Place the second largest element at correct
position
● Third Pass:
● Place the remaining two elements at their
correct positions. Java Searching Algorithm – used to locate
specific items within a collection of data.
● Total no. of passes: n-1 Designed to efficiently navigate structures to
● Total no. of comparisons: n*(n-1)/2 find through the data desired information,
making them fundamental in various
applications such as databases, web search
engines, and more.
In this algorithm,
● Data
● Pointer to left child
● Pointer to right child
minimum in O(1) time complexity.
• Represent hierarchical data.
• Used in editing software like Microsoft Excel
and spreadsheets.
• Useful for indexing segmented at the database
is useful in storing cache in the system,
• Syntax trees are used for most famous
compilers for programming like GCC, and AOCL
to perform arithmetic operations.
• For implementing priority queues.
• Used to find elements in less time (binary
search tree)
• Used to enable fast memory allocation in
computers.
• Used to perform encoding and decoding
Below is an example of a tree node with integer
operations.
data: • Binary trees can be used to organize and
retrieve information from large datasets, such
as in inverted index and k-d trees.
• Binary trees can be used to represent the
decision-making process of computer controlled
characters in games, such as in decision trees.
• Binary trees can be used to implement
searching algorithms, such as in binary search
trees which can be used to quickly find an
element in a sorted list.
• Binary trees can be used to implement sorting
algorithms, such as in heap sort which uses a
Basic Operation On Binary Tree:
binary heap to sort elements efficiently.
• Inserting an element.
• Removing an element. Binary Tree Traversals
• Searching for an element.
Tree Traversal algorithms can be classified
• Traversing the tree.
broadly into two categories:
Auxiliary Operation On Binary Tree:
• Depth-First Search (DFS) Algorithms
• Finding the height of the tree
• Breadth-First Search (BFS) Algorithms
• Find the level of a node of the tree.
• Finding the size of the entire tree. Depth-First Search (DFS)
Applications of Binary Tree Tree Traversal using Depth-First Search (DFS)
• In compilers, Expression Trees are used which algorithm can be further classified into three
is an application of binary trees. categories:
• Huffman coding trees are used in data • Preorder Traversal (current-left-right)
compression algorithms. • Inorder Traversal (left-current-right)
• Priority Queue is another application of binary • Postorder Traversal (left-right-current)
tree that is used for searching maximum or
Preorder Traversal (current-left-right): • Level-order Traversal of the above tree:
• Visit the current node before visiting any 1-2-3-4-5-6-7
nodes inside the left or right subtrees.
• Here, the traversal is root – left child – right
child. It means that the root node is traversed
first then its left child and finally the right child.
Indexing
Disadvantages of Indexing