DS Viva Questions and Answers
DS Viva Questions and Answers
5. Name three sorting algorithms and mention their average time complexities.
c
CopyEdit
struct Node {
int data;
struct Node* next;
};
Expression evaluation
Undo operation in editors
3. Define hashing.
Hashing is a technique used to uniquely identify a specific object from a group of similar objects
using a hash function.
Chaining
Open Addressing (Linear probing, Quadratic probing, Double hashing)
Answer:
An Abstract Data Type defines the logical behavior of a data structure without specifying
implementation.
Example:
2. Compare Linear Search and Binary Search. Which is better and when?
Feature Linear Search Binary Search
Best Technique: Use Insertion Sort for small datasets or nearly sorted arrays.
Best Technique: Use Doubly Linked Lists when bidirectional access is needed.
At beginning: O(1)
At end: O(n)
After specific node: O(1)
c
CopyEdit
newNode->next = current->next;
current->next = newNode;
3. Compare arrays and linked lists.
Feature Array Linked List
Array:
c
CopyEdit
top++;
stack[top] = value; // push
value = stack[top]; top--; // pop
Linked List:
c
CopyEdit
push: insert at head
pop: delete from head
Feature Array Linked List
Postfix Evaluation:
Operations:
Collision Resolution:
Best Technique: Use Double Hashing for minimal clustering and high load factors.