Sei sulla pagina 1di 5

Q1.

Write a note on binary tree

A binary tree is a finite set of nodes that is either empty or consist a


root node and two disjoint binary trees called the left subtree and the
right subtree.
In other words, a binary tree is a non-linear data structure in which
each node has maximum of two child nodes. The tree connections can
be called as branches. Trees are used to represent data in hierarchical
form.
Binary tree is the one in which each node has maximum of two child-
node.
The order of binary tree is ‘2’.
Binary tree does not allow duplicate values.
While constructing a binary, if an element is less than the value of its
parent node, it is placed on the left side of it otherwise right side.
A binary tree is shown for the element 40, 56, 35, 48, 22, 65, 28.
Following there is an example of binary search tree:
Advantages of Binary Tree:
1. Searching in Binary tree become faster.
2. Binary tree provides six traversals.
3. Two of six traversals give sorted order of elements.
4. Maximum and minimum elements can be directly picked up.
5. It is used for graph traversal and to convert an
6. expression to postfix and prefix forms.
1) Complete Binary Tree

A binary tree T is said to be complete binary tree if


All its levels, except possibly except possibly the last, have the
maximum number of nodes and
All the nodes at the last level appears as far left as possible.
Consider the following tree, which is complete binary tree:
Note: Full binary tree is also called complete binary tree.
IF L is the level of complete binary tree then 2L – 1 nodes present in the
tree.
2) Strictly Binary Tree

When every non leaf node in a binary tree is filled with left and right
subtrees, the tree is called a strictly binary tree.
3) Extended Binary Tree

The binary tree that is extended with zero (no nodes) or left or right
node or both the nodes is called an extended binary tree or a 2- tree.
The extended binary tree is shown in figure above. The extended nodes
are indicated by square box. Maximum nodes in the binary tree have
one child (nodes) shown at either left or right by adding one or more
children, the tree can be extended. The extended binary tree is very
useful for representation of algebraic expressions. The left and right
child nodes denote operands and parent node indicates operator.

Q.2Write a note on Circular linked list


Circular linked list is a linked list where all nodes are
connected to form a circle. There is no NULL at the end.
A circular linked list can be a singly circular linked list or
doubly circular linked list.
Advantages of Circular Linked Lists: 1) Any node can be a
starting point. We can traverse the whole list by starting
from any point. We just need to stop when the first
visited node is visited again.
2) Useful for implementation of queue.
Unlike this implementation, we don’t need to maintain
two pointers for front and rear if we use circular linked
list. We can maintain a pointer to the last inserted node
and front can always be obtained as next of last.
3) Circular lists are useful in applications to repeatedly go
around the list. For example, when multiple applications
are running on a PC, it is common for the operating
system to put the running applications on a list and then
to cycle through them, giving each of
them a slice of time to execute, and then making them
wait while the CPU is given to another application. It is
convenient for the operating system to use a circular list
so that when it reaches the end of the list it can cycle
around to the front of the list.
4) Circular Doubly Linked Lists are used for
implementation of advanced data structures
like Fibonacci Heap.

Q 3. Difference Between Singly linked list And


Doubly linked list
Singly linked list Doubly linked list
1. lSingly linked list 1.Doubly linked list
(SLL) (DLL)
2. SLL has nodes with 2.DLL has nodes with
only a data field and a data field, a previous
next link field. link field and a next
3. link field.
4. In SLL, the traversal 3.In SLL, the traversal
can be done using can be done using the
the next node link next node link only
only
5. In SLL, the traversal 4.The DLL occupies
can be done using more memory than
the next node link SLL as it has 3
only.The SLL fields.More
occupies less
memory than DLL as
it has only 2 fields
6. Less efficient access 5.More efficient to
to elements access to element

Potrebbero piacerti anche