dsa 2nd internal
dsa 2nd internal
A Heap is a complete binary tree data structure that satisfies the heap
property: for every node, the value of its children is greater than or equal
to its own value. Heaps are usually used to implement priority queues,
where the smallest (or largest) element is always at the root of the tree.
I Initialize:
IV Output:
6. What is linklist?
A Linked List is a dynamic data structure that consists of nodes, where each node
contains two parts:
Steps:
Output:
Steps:
1. Initialize:
o Create an empty stack for operators.
o Initialize an empty string for the postfix expression.
2. Read the Expression:
o Scan the infix expression from left to right.
3. Handle Each Token:
o If the token is an operand (e.g., A, B, 1, 2):
Append it directly to the postfix expression.
o If the token is an opening parenthesis (():
Push it onto the stack.
o If the token is a closing parenthesis ()):
Pop from the stack and append to the postfix expression until an
opening parenthesis is encountered.
Discard the opening parenthesis.
o If the token is an operator (e.g., +, -, *, /):
While the stack is not empty and the top of the stack has higher or
equal precedence than the current operator:
Pop from the stack and append to the postfix expression.
Push the current operator onto the stack.
4. After Scanning:
o If there are any operators left in the stack, pop them and append to the postfix
expression.
5. Return:
o The resulting postfix expression.
Preorder Traversal: A B D E C F
Inorder Traversal: D B E A F C
Step-by-Step Solution:
Otherwise:
14.Sparx Array
A sparse matrix is a two-dimensional array (matrix) where most of the elements are zero. It is often
represented in a more compact form to save memory and computational resources.
15.hashing?
Hashing is a technique used to uniquely identify a value or object from a collection of values. It
transforms data (such as a string, number, or object) into a fixed-size value, typically a hash code.
This transformation is done using a function called a hash function. Hashing is commonly used in
data structures like hash tables, sets, and caches to quickly access and store data.