Viva Q&A - DDS
Viva Q&A - DDS
Viva Q&A - DDS
4. Define structure.
A structure is a user-defined data type that allows the grouping of variables of different data
types under a single name.
8. What is a pointer?
A pointer is a variable that stores the memory address of another variable.
9. How will you access members of a structure? Write the syntax for that.
You can access members of a structure using the dot operator for normal structures and the
arrow operator for pointers to structures:
11. How many functions are there in DMA and what are they?
Common functions in DMA include:
malloc()
calloc()
realloc()
free()
Pop: Remove and return the top element from the stack.
Dequeue: Remove and return the front element from the queue.
21. How will you state that the stack is in the initial position and full in array representation?
22. How will you state that the stack is in the initial position and full in linked list representation?
Full: Not applicable, as a linked list can grow until memory is exhausted.
23. How will you state that the queue is in the initial position and full in array representation?
24. How will you state that the queue is in the initial position and full in linked list representation?
Full: Not applicable, as a linked list can grow until memory is exhausted.
Indirect recursion: A function calls another function, which then calls the first function.
28. What is a circular queue?
A circular queue is a linear data structure where the last position is connected back to the first
position to make the queue circular.
Array Representation: Uses an array to represent the tree, where for a node at index :
Parent is at index
Pointer Representation: Each node contains pointers to its left and right children.
Preorder Traversal: Visit the root, traverse the left subtree, then traverse the right subtree.
Inorder Traversal: Traverse the left subtree, visit the root, then traverse the right subtree.
Postorder Traversal: Traverse the left subtree, traverse the right subtree, then visit the root.
Level Order Traversal: Visit nodes level by level, starting from the root.
Insertion: Adding a new node while maintaining the binary tree properties.
Deletion: Removing a node and reorganizing the tree to maintain its properties.
Insertion: Start at the root; compare the value with the current node. If smaller, go left; if larger,
go right. Insert when a null pointer is reached.
2. Node with one child: Replace the node with its child.
3. Node with two children: Find the in-order successor (smallest in the right subtree), replace the
node's value with it, and delete the successor.
Searching: Start at the root; traverse left or right depending on whether the target value is
smaller or larger than the current node until found or a null pointer is reached.
Traversals: Can be performed using preorder, inorder, postorder, or level order methods.
Single Right Rotation (LL Rotation): Performed when a node is added to the left subtree of the
left child.
Single Left Rotation (RR Rotation): Performed when a node is added to the right subtree of the
right child.
Left-Right Rotation (LR Rotation): Performed when a node is added to the right subtree of the
left child.
Right-Left Rotation (RL Rotation): Performed when a node is added to the left subtree of the
right child.
Red nodes cannot have red children (no two reds in a row).
Every path from a node to its descendant null nodes must have the same number of black
nodes.
Static Hashing: The size of the hash table is fixed, and collisions are handled using techniques
such as chaining or open addressing.
Dynamic Hashing: The hash table can grow or shrink in size as needed, allowing for efficient
memory usage and handling a varying number of entries.
Chaining: Each bucket in the hash table points to a linked list of entries that hash to the same
index.
Open Addressing: When a collision occurs, the algorithm searches for the next available slot
using a probing sequence (e.g., linear probing, quadratic probing).
Double Hashing: Uses a second hash function to calculate the next index when a collision
occurs.
Undirected Connections: Edges do not have a direction (connect two vertices symmetrically).
Weighted Connections: Edges have weights (costs associated with traversing them).
Bipartite Graph: Vertices can be divided into two disjoint sets, with edges only between sets.
Adjacency Matrix: A 2D array where each cell indicates the presence or absence of an edge
between vertices.
Adjacency List: An array of lists where each index represents a vertex and stores a list of its
adjacent vertices.