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

Ds 2 Mark Questions

The document defines key concepts in data structures, including Extended Binary Trees, Linked Lists as ADTs, and tree traversal methods. It discusses AVL Trees, their balancing properties, and practical applications of various tree types. Additionally, it covers Huffman Encoding for data compression and compares Singly and Doubly Linked Lists.

Uploaded by

omkarkera2006
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)
7 views3 pages

Ds 2 Mark Questions

The document defines key concepts in data structures, including Extended Binary Trees, Linked Lists as ADTs, and tree traversal methods. It discusses AVL Trees, their balancing properties, and practical applications of various tree types. Additionally, it covers Huffman Encoding for data compression and compares Singly and Doubly Linked Lists.

Uploaded by

omkarkera2006
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/ 3

1.

Define the term 'Extended Binary Tree':


An Extended Binary Tree (also called a 2-tree) is a binary tree where all original nodes with two children are
converted to internal nodes, and additional nodes are added as external nodes (leaves). These additional nodes
replace any missing child (left or right) of the original tree, ensuring that every internal node has exactly two
children.

2. Explain Linked List as an ADT (Abstract Data Type):


A Linked List is an ADT that consists of a collection of nodes, where each node contains data and a reference (or
link) to the next node in the sequence. It provides dynamic memory allocation, allowing insertion and deletion of
nodes without reallocation or reorganization of the entire structure.

3. C function for Inorder Traversal of Tree:

void inorder(struct Node* root) {


if (root == NULL)
return;
inorder(root->left);
printf("%d ", root->data);
inorder(root->right);
}

4. Process of Pre-order Traversal of Binary Tree (Example):


In pre-order traversal, we first visit the root node, then recursively traverse the left subtree, and finally the right
subtree. Example for the tree:

A
/ \
B C
/ \
D E

Pre-order: A -> B -> D -> E -> C

5. C function to count number of nodes in Singly Linked List:

int countNodes(struct Node* head) {


int count = 0;
struct Node* current = head;
while (current != NULL) {
count++;
current = current->next;
}
return count;
}

6. Tree Structure for the Expression ((a - 3b) * (2x - y)):


The tree structure for the expression ((a - 3b) * (2x - y)) would look like this:

markdown

*
/ \
- -
/ \ / \
a 3b 2x y

7. Comparison of Singly and Doubly Linked List:

Singly Linked List Doubly Linked List


Each node contains data and a single link to Each node contains data and two links: one to the next node and
the next node. one to the previous node.
Supports forward traversal only. Supports both forward and backward traversal.
Uses less memory (one pointer per node). Uses more memory (two pointers per node).
Simpler to implement. More complex but provides better flexibility.

8. Declare the structure of node in Linked List:

struct Node {
int data;
struct Node* next;
};

9. Discuss AVL Trees with Example:


An AVL Tree is a self-balancing binary search tree where the difference in heights of the left and right subtrees of
any node (the balance factor) is at most 1. Whenever an insertion or deletion operation causes the tree to become
unbalanced, it is rebalanced using rotations. Example: If we insert nodes with values 10, 20, and 30 into an AVL
tree, it will require a left rotation to balance the tree.

10. Practical Applications of Trees:

Binary Search Tree: Used in searching algorithms.


Huffman Trees: Used in data compression.
Expression Trees: Used to evaluate mathematical expressions.
Trie (Prefix Tree): Used in dictionary and autocomplete systems.

11. Define Traversal of Binary Tree & Types of Traversal:


Traversal is the process of visiting all the nodes in a binary tree in a specific order. Types:

In-order Traversal: Left, Root, Right


Pre-order Traversal: Root, Left, Right
Post-order Traversal: Left, Right, Root
Level-order Traversal: Level by level from top to bottom.

12. What is the use of Huffman Encoding?:


Huffman encoding is used in data compression to reduce the size of files. It assigns shorter codes to more
frequent characters and longer codes to less frequent characters, leading to efficient data representation.

You might also like