Itedat Notes
Itedat Notes
- The Last-In-First-Out (LIFO) principle governs the behavior of - A queue is a linear data structure where elements are stored in
stacks. the FIFO (First In First Out) principle where the first element
inserted would be the first element to be accessed. A queue is an
- Last element added is removed first, Ordered in reverse Abstract Data Type (ADT) similar to stack, the thing that makes
chronological order, Restricted access to top element and queue different from stack is that a queue is open at both its ends.
Elements are added and removed sequentially. The data is inserted into the queue through one end and deleted
from it using the other end. Queue is very frequently used in most
- Stack Application: programming languages.
1. Parsing expressions - Stacks can be used to parse expressions - A real-world example of queue can be a single-lane one-way
and evaluate postfix notation. road, where the vehicle enters first, exits first. More real-world
2. Recursive algorithms - Stacks can be used to implement examples can be seen as queues at the ticket windows and bus-
recursive algorithms iteratively. stops.
Three-Dimensional Arrays: - Leaves are nodes with no children, while the height of a tree is
defined by the longest path from the root to a leaf node, indicating
You can imagine it like a cuboid its depth.
made up of smaller cuboids where
each cuboid can contain an Subtrees and Levels
element.
- A subtree is a section of the tree that includes a node and all its
descendants, while the level of a tree denotes the depth of a node,
providing a way to categorize nodes based on their distance from - This representation of a linked list depicts that each node
the root. consists of two fields.
Representation of Tree - The first field consists of data, and the second field consists of
pointers that point to another node.
TYPES OF LINKED LISTS
SINGLY LINKED LIST
A singly linked list is a fundamental linear data structure where
each element, called a node, contains two parts:
1. Data: The value stored in the node.
2. Next Pointer: A reference to the next node in the
sequence.