0% found this document useful (0 votes)
29 views3 pages

Data Structures: Queues, Trees, Lists

The document provides an overview of various data structures including circular queues, priority queues, stacks, linked lists, binary trees, AVL trees, and B-trees. It explains their properties, operations, and applications, such as traversal methods for trees and the use of heaps in priority queues. Key traversal techniques like in-order, pre-order, post-order, and level-order are also discussed, highlighting their use cases and implementations.

Uploaded by

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

Topics covered

  • Data Structure Types,
  • Data Retrieval,
  • Searching,
  • Abstract Data Types,
  • Pre-order Traversal,
  • Deletion,
  • Expression Trees,
  • Data Organization,
  • Level-Order Traversal,
  • Complexity Analysis
0% found this document useful (0 votes)
29 views3 pages

Data Structures: Queues, Trees, Lists

The document provides an overview of various data structures including circular queues, priority queues, stacks, linked lists, binary trees, AVL trees, and B-trees. It explains their properties, operations, and applications, such as traversal methods for trees and the use of heaps in priority queues. Key traversal techniques like in-order, pre-order, post-order, and level-order are also discussed, highlighting their use cases and implementations.

Uploaded by

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

Topics covered

  • Data Structure Types,
  • Data Retrieval,
  • Searching,
  • Abstract Data Types,
  • Pre-order Traversal,
  • Deletion,
  • Expression Trees,
  • Data Organization,
  • Level-Order Traversal,
  • Complexity Analysis

1.

Circular Queue

A circular queue is a linear data structure that operates in a circular manner. It overcomes the
limitation of a simple queue, where once the queue is full, no more elements can be inserted
even if there is space available at the beginning. In a circular queue, the last position is
connected to the first position, forming a circular structure.

2. Priority Queue

A priority queue is a special type of queue where each element is associated with a priority
value. Elements are inserted and deleted based on their priority. The element with the highest
priority is always at the front of the queue.

3. ADT Stack and Its Operations

An Abstract Data Type (ADT) stack is a linear data structure that follows the Last-In-First-Out
(LIFO) principle. The basic operations on a stack are:
* Push: Adds an element to the top of the stack.
* Pop: Removes the element from the top of the stack.
* Peek: Returns the top element without removing it.
* IsEmpty: Checks if the stack is empty.
* IsFull: Checks if the stack is full.

4. Doubly Linked List

A doubly linked list is a linear data structure where each node contains data, a pointer to the
next node, and a pointer to the previous node. This allows for traversal in both forward and
backward directions.

5. Circular Linked List

A circular linked list is similar to a singly linked list, but the last node points back to the first
node, forming a circular structure.

[Link] tree:

Binary tree has at most two children: a left child and a right child.
Binary trees have various applications, including:
* Binary Search Tree (BST): Used for efficient searching, insertion, and deletion of elements.
* Heap Tree: Used for priority queue implementation and sorting algorithms.
* Expression Trees: Used to represent and evaluate arithmetic expressions.
* Huffman Coding Trees: Used for data compression.

7. AVL Tree

An AVL tree is a self-balancing binary search tree where the heights of the two child subtrees of
any node differ by at most one. This ensures efficient search, insertion, and deletion operations.

8. B-Tree and B+ Tree

* B-Tree: A balanced tree that is used for efficient storage and retrieval of data in databases
and file systems.
* B+ Tree: A variant of the B-tree, where all data is stored in leaf nodes, and internal nodes only
store keys to direct searches. B+ trees are optimized for efficient range queries.

9. Traversing, Insertion, Deletion, and Searching in Linked Lists

* Traversing: Visiting each node in a linked list in a specific order (e.g., forward, backward).
* Insertion: Adding a new node to a linked list at a specific position.
* Deletion: Removing a node from a linked list.
* Searching: Finding a specific node in a linked list based on its data value.

10. Heap Tree

A heap tree is a specialized binary tree that satisfies the heap property: for any node, the key of
the node is greater than or equal to the keys of its children (in a max heap) or less than or equal
to the keys of its children (in a min heap). Heap trees are used for efficient implementation of
priority queues.

11. Tree Traversing

Tree Traversal
Tree traversal refers to the process of visiting each node in a tree exactly once. There are
primarily three types of tree traversals:
1. In-order Traversal:
* Order: Left Subtree -> Root -> Right Subtree
* Use Case: For binary search trees, in-order traversal yields nodes in ascending order.
* Example: Consider the following binary tree:
8
/ \
3 10
/\ \
1 6 14

The in-order traversal would visit the nodes in the following order: 1, 3, 6, 8, 10, 14.
2. Pre-order Traversal:
* Order: Root -> Left Subtree -> Right Subtree
* Use Case: Creating a prefix expression of an expression tree.
* Example: For the same tree as above, the pre-order traversal would be: 8, 3, 1, 6, 10, 14.
3. Post-order Traversal:
* Order: Left Subtree -> Right Subtree -> Root
* Use Case: Deleting a binary tree or evaluating a postfix expression.
* Example: The post-order traversal of the tree would be: 1, 6, 3, 14, 10, 8.
Visual Representation:
Implementation:
These traversals can be implemented recursively or iteratively using a stack. Here's a recursive
Python implementation for in-order traversal:
def inorderTraversal(root):
if root:
inorderTraversal([Link])
print([Link])
inorderTraversal([Link])

Level-Order Traversal (Breadth-First Search):


* Order: Level by Level
* Use Case: Finding the minimum depth of a tree or printing the nodes level by level.
* Implementation: This traversal is typically implemented using a queue.
Key Points:
* The choice of traversal method depends on the specific task and the properties of the tree.
* In-order traversal is particularly useful for binary search trees.
* Pre-order and post-order traversals are often used for expression trees and tree deletion.
* Level-order traversal is useful for tasks like finding the height or width of a tree.
By understanding these traversal techniques, you can effectively navigate and manipulate tree
structures in various algorithms and data structures.

You might also like