Data Structures With C
Data Structures With C
1.10 Write the condition for stack full and stack empty?
Ans: Stack full
Top==max -1.
Stack empty
Top==-1.
2.3 What are the types of linked list and explain anyone?
Ans: a. Singly Linked Lists
b. Doubly Linked Lists
c. Circular Singly Linked Lists
d. Circular Doubly Linked Lists
For example:
ptr = (float*) calloc(25, sizeof(float));
2 Preorder
Preorder traversal in a binary tree can be performed
recursively by
following order.
1. Visit the root node ( Root )
2. Traverse the left sub tree in preorder recursively (Left )
3 Traverse the right sub tree in preorder recursively (right )
void preorder( Node root)
{
if(root ==NULL)
return ;
printf(“\n%d “, root->data);
preorder(root->llink);
preorder(root->rlink);
}
Preorder Traversal = Root->Left->Right
3 Postorder
Preorder traversal in a binary tree can be performed
recursively by
following order.
1. Traverse the left sub tree in postorder recursively (Left)
2. Traverse the right sub tree in postorder recursively
(right)
3. Visit the root node (Root)
void postorder( Node root)
{
if(root ==NULL)
return ;
postorder(root->llink);
postorder(root->rlink);
printf(“\n%d “, root->data);
}
Postorder Traversal = Left->Right->Root.
Void Pointer:
A void pointer is a pointer that has no associated
data type with it. A void pointer can hold address
of any type and can be typcasted to any type.
int a = 10;
char b = 'x';
2. Circular Queue
In Circular queue elements will be inserted and
deleted in a circular fashion. Circular queue follows
FIFO (First in First Out). Pictorial representation of
Circular queue.
3. Priority Queue
Priority queue is a special type of data structure
in which items can be inserted or deleted based on
the given priority. Always an element with highest
priority is
processed before processing the lowest priority
elements. If the elements in the queue come with
same or equal priority, then the element which is
inserted first will be
processed first.
2) Parent:
A parent is a node that has any number of
child nodes. In simple terms, a parent node is the
one that has branches (child nodes) extending from
it.
3) Descendants:
Descendants in a tree refer to all the
nodes that can be reached from specific node.
4) Root node:
The initial node in the tree or first node in
the tree is known as root node.