important DS question
important DS question
important DS question
Advantages
Dynamic data structure: A linked list is a dynamic
arrangement so it can grow and shrink at runtime by
allocating and deallocating memory. So there is no
need to give the initial size of the linked list.
No memory wastage: In the Linked list, efficient
memory utilization can be achieved since the size of
the linked list increase or decrease at run time so
there is no memory wastage and there is no need to
pre-allocate the memory.
Disadvantages
Memory usage: More memory is required in the
linked list as compared to an array. Because in a
linked list, a pointer is also required to store the
address of the next element and it requires extra
memory for itself.
Traversal: In a Linked list traversal is more time-
consuming as compared to an array. Direct access to
an element is not possible in a linked list as in an
array by index. For example, for accessing a node at
position n, one has to traverse all the nodes before it.
Postfix: ab+cd+*f/
Prefix*+ab+cd/f
4. What are the limitations of linear queue? How they can be rectified?
In Binary Search Tree, every node In AVL Tree, every node follows
does not follow the balance factor. the balance factor i.e. 0, 1, -1.
The height or depth of the tree is The height or depth of the tree is
O(n). O(logn)
1. Balance Factor:
height(N.right).
2. Balanced Condition:
Queue
Queue is a collection of one or more elements
arranged Static Queue is always fixed size.
in memory in a contiguous fashion. In Queue,
only one and single type of information is stored
because static Queue implementation is through
Array. Static Queue is index based.
1. The key in the root is the maximum key. Save its value to return.
2. Identify the node to be deleted, unfilling bottom level right-to-left.
3. Move the key in the node to be deleted to the root, and delete the node.
7. Prove that the maximum number of edges that a graph with n Vertices is n*(n-
1)/2.