Data Structures Viva Question
Data Structures Viva Question
4. What is Stack?
A stack is a list of elements in which insertion and deletions can take place only at
one end, this end is called as stack 'top'. Only top element can be accessed. A stack
data structure has LIFO (Last In First Out) property. A stack is an example of linear
data structure.
In B-Tree, internal nodes can have a variable number of child nodes within some
pre-defined range. A B-tree is kept balanced by requiring that all leaf nodes are at
the same depth.
First pass bubbles out the largest element and places it in the last position and
second pass places the second largest element in the second last position and so
on. Thus in the last pass smallest element is placed in the first position.
The running time is the total number of comparisons that is n(n-1)/2 which implies
O(n2) time complexity.
The running time is the total number of comparisons that is n(n-1)/2 which implies
O(n2) time complexity.
The running time is the total number of comparisons that is n(n-1)/2 which implies
O(n2) time complexity.
If the running time of merge sort for a list of length n is T(n) then the recurrence
relation is T(n) = 2T(n/2) + n, thus after simplifying the recurrence relation T(n) =
O(nlogn).
Adjacency matrix is a two dimensional arrays where for each edge, (u,v) A[u,v] = true
otherwise it will be false. The space complexity to represent a graph using this is
O(|V|2).
Adjacency list are used where each list stores adjacent vertices of the corresponding
vertex. The space complexity to represent a graph using this is O(|V|+|E|).