Jeshwanth Ds
Jeshwanth Ds
71 to 85
71<85, hence the right half must hold the key.
Refresh the boundaries: Low = 7.
Low = 7, High = 8.
High is 8.
Recalculate the Middle Index in Step Three.
Actions to take:
Verify whether the stack is full:
In the event that top = capacity −1, print "Stack Overflow."
If not, increase top top.
The new element should go at array[top]array[top].
The algorithm
text
Code push(stack, element) is copied:
Should top equal capacity minus one, print "Stack Overflow"
stack[top] = element; return top = top + 1
4. Evaluate the following postfix notation of expression (Show
status of stack after execution of each operations): 520 15-252*+
Stack
Step Token Action Explanation
(Status)
1 520 Push 520 onto the stack. [520] Operand, push onto stack.
[520,
2 15 Push 15 onto the stack. Operand, push onto stack.
15]
-
Pop 15 and 520, compute [505]
520−15=505520 - 15 =
3
520−15520 - 15520−15. 505520−15=505, push the result.
[505,
4 252 Push 252 onto the stack. Operand, push onto stack.
252]
Pop 252 and 505, compute 505×252=127260505 \times 252 =
5 * 505×252505 \times [127260] 127260505×252=127260, push the
252505×252. result.
Pop 127260, compute 127260+0=127260127260 + 0 =
6 + 127260+0127260 + [127260] 127260127260+0=127260, push the
0127260+0. result.
There can be more than one kid per node in the tree.
With the possible exception of the leaf level, the tree's structure is
perfectly balanced.
Full Binary Tree: An entire binary tree is one in which:
Every level is fully occupied, with the possible exception of the final
one.
The last level's nodes are oriented as far to the left as feasible.
Important Distinctions:
Nodes in the last level of a full binary tree can be empty or have just
one child as long as they are filled from left to right.
Unlike a complete binary tree, it does not require every node to have
two offspring.
Key Comparison:
Property Full Binary Tree Complete Binary Tree
Each node has 0 or 2 Nodes may have 0, 1, or
Node Children
children. 2 children.
Property Full Binary Tree Complete Binary Tree
No specific alignment
Last Level Nodes are left-aligned.
rule.
Starting from a selected vertex, DFS moves as far as it can along each
branch before turning around.
DFS uses a recursive or stack-based approach to graph exploration.
Each vertex may only be visited once, and each edge may only be
examined once.
Complexity of DFS Time:
Every vertex and edge in the entire graph will be investigated by the
DFS algorithm.
Since it's of order 3, each node may only contain a maximum of two
keys (M−1=3−1=2, hence 𝑀−1 = 3−1 = 2).
Step-by-Step Insertion into the M-way Search Tree
1. Insert 20:
o The tree is empty, so 20 becomes the root.
o The tree looks like this:
csharp
Copy code
[20]
2. Insert 70:
o 70 is greater than 20, so it is inserted to the right of 20.
o The tree now contains two keys: 20 and 70.
o The tree looks like this:
csharp
Copy code
[20, 70]
3. Insert 110:
o 110 is greater than 70, so it is inserted to the right of 70.
o Since the node now has 3 keys (more than the allowed 2),
we split the node.
o The middle key (70) is moved up to become the new root,
and the other two keys (20 and 110) are split into two
nodes.
o The tree now looks like this:
csharp
Copy code
[70]
/ \
[20] [110]
1. Insert 210:
o 210 is greater than 110, so it is inserted to the right of
110.
o The tree now looks like this:
csharp
Copy code
[70]
/ \
2. [20] [110, 210]
3. Copy code
4. Insert 130:
o 130 is greater than 110 but less than 210, so it is inserted
between 110 and 210.
o The node [110, 210] will now have 3 keys (110, 130, 210),
which causes a split.
o The middle key (130) moves up to the root, and the node
is split into two nodes: [110] and [210].
o The tree now looks like this:
css
Copy code
[70, 130]
/ | \
[20] [110] [210]