0% found this document useful (0 votes)
2 views2 pages

Itedat Notes

The document provides an overview of various data structures including stacks, queues, arrays, trees, and linked lists. It explains their definitions, principles, operations, and applications, highlighting concepts such as LIFO and FIFO for stacks and queues, respectively. Additionally, it covers different types of trees and linked lists, along with traversal techniques and memory management aspects.

Uploaded by

jwlxen06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views2 pages

Itedat Notes

The document provides an overview of various data structures including stacks, queues, arrays, trees, and linked lists. It explains their definitions, principles, operations, and applications, highlighting concepts such as LIFO and FIFO for stacks and queues, respectively. Additionally, it covers different types of trees and linked lists, along with traversal techniques and memory management aspects.

Uploaded by

jwlxen06
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

ITEDAT NOTES - 2D → Use 2 coordinates: [row][col]

Topic 1: Stacks - 3D → Use 3 coordinates: [depth][row][col]. Think of 3D as


layers of 2D grids
- A stack is a linear data structure that follows a specific order for
adding and removing elements, making it essential in
programming for managing data and controlling the flow of
operations. Topic 3: Queue

- 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.

- Stack Implementation Basic Operations in Queue

1. Array-based Stack - Queue operations also include initialization of a queue, usage


and permanently deleting the data from the memory.
An array-based stack is a type of stack data structure that uses a
fixed-size array to store elements. - The most fundamental operations inthe queue ADT include:
enqueue(),dequeue(), peek(), isFull(), isEmpty().These are all
2. Linked-list-based Stack built-in operations to carry out data manipulation and to check
the status of the queue.
A linked-list-based stack is a stack that uses a linked list to store
its elements. - Queue uses two pointers − front and rear. The front pointer
accesses the data from the front end (helping in enqueueing)
Common Uses while the rear pointer accesses data from the rear end (helping in
dequeuing).
1. Managing function calls - Stacks are used to manage function
calls and returns in programming languages.  - insert / enqueue − add an item to the
2. Undo/redo functionality - Stacks can be used to implement rear of the queue.
undo/redo functionality in text editors and other applications.  remove / dequeue − remove an item
Stack operations: Basic actions to add, remove, or view items in from the front of the queue.
a stack. Always interact with the top of the stack  Peek − get the element at front of the queue.
Push Operation: Add an item to the top of the stack Push  isFull − check if queue is full.
Pop Operation: Remove the top item of the stack  isEmpty − check if queue is empty.
Peek: View the top item without removing it Circular Queue Data Structure
isEmpty: Check if the stack has no items - A circular queue is a type of queue in which the last position is
connected back to the first position to make a circle. It is also
known as a Ring Buffer. In a normal queue, once the queue
Topic 2: Arrays becomes full, we cannot insert the next element even if there is a
space in front of the queue. But using a circular queue, we can use
- An array is a linear data structure that collects elements of the the space to insert elements. It is a linear data structure that
same data type and stores them in contiguous and adjacent follows the FIFO mechanism. The circular queue is a more
memory locations. Arrays work on an index system starting from efficient way to implement a queue in a fixed size array. In a
0 to (n-1), where n is the size of the array. circular queue, the last element points to the first element making
One-Dimensional Arrays: a circular link.

You can imagine a 1d Topic 4: Tree


array as a row, where elements are stored one after another. - A tree is a hierarchical model consisting of nodes connected by
Two-Dimensional Arrays (2D) edges, representing parent-child relationships and facilitating
efficient data organization.
- Used in numerous applications including databases, file
You can imagine it systems, and network routing, trees support efficient searching
like a table where and retrieval processes.
each cell contains
elements. Leaves and Height of a Tree
- Nodes, edges, and roots Nodes are fundamental components of
a tree, while edges are the connections between them; the root
node is the topmost point from which all nodes descend.

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.

- A binary tree is a tree structure in which each node has at most


two children; this simplifies various operations and enhances data
organization.
- A Ternary Tree data structure in which each node has at most
Doubly Linked List
three child nodes, usually distinguished as “left”, “mid” and
“right”. This structure extends the concept of binary trees by - A doubly linked list is a bi-directional linked list. So, you can
allowing an additional child per node traverse it in both directions. Unlike singly linked lists, its nodes
contain one extra pointer called the previous pointer. This pointer
- N-ary Tree is a collection of nodes where each node is a data
points to the previous node.
structure that consists of records and a list of references to its
children. Each node stores the address of multiple nodes.
Tree Traversal Techniques

CIRCULAR LINKED LIST

 A Circular Linked List (CLL) is a variation of a linked


list.

 The last node points back to the first node, creating a


continuous loop.

 Can be either singly (one-way) or doubly (two-way)


circular.

Inorder traversal (Left Root Right) - In order traversal visits


the left subtree, then the current node, and finally the right
subtree, commonly used in binary search trees.
Preorder traversal (Root Left Right) - Preorder traversal visits
the current node before its left and right subtrees, often used for
creating a copy of the tree.
Postorder traversal (Left Right Root) - Postorder traversal Circular Doubly Linked List
visits the left and right subtrees before the current node, useful for
deleting the tree or evaluating expressions. A circular doubly linked list is a mixture of a doubly linked list
and a circular linked list. Like the doubly linked list, it has an
Level-order traversal (Level by Level) - Level-order traversal extra pointer called the previous pointer, and similar to the
processes nodes level by level, starting from the root and moving circular linked list, its last node points at the head node. This type
downward, effectively handling trees that are wide and shallow. of linked list is the bi-directional list. So, you can traverse it in
both directions.

Topic 5: Linked List


- A linked list is a linear data structure that stores a collection of
data elements dynamically.
- Nodes represent those data elements, and links or pointers
connect each node.
- Each node consists of two fields, the information stored in a
linked list and a pointer that stores the address of its next node.
- The last node contains null in its second field because it will
point to no node.
- A linked list can grow and shrink its size, as per the requirement.
- It does not waste memory space
Representation of
Linked List

You might also like