Q1 |
What is a linked list? How does it differ from an array? |
A1 |
A linked list is a linear data structure where elements are stored in separate nodes, each containing a reference to the next node. Unlike an array, linked lists can dynamically grow and shrink in size. |
Q2 |
Explain the concept of singly linked list and doubly linked list. |
A2 |
In a singly linked list, each node contains a reference to the next node. In a doubly linked list, each node contains references to both the next node and the previous node. |
Q3 |
What are the common operations performed on a singly linked list and a doubly linked list? |
A3 |
Common operations on a singly linked list include insertion, deletion, traversal, and searching. Common operations on a doubly linked list also include backward traversal and insertion/deletion at the tail. |
Q4 |
How can you implement a stack and a queue using a singly linked list? |
A4 |
A stack can be implemented using a singly linked list by performing push and pop operations at the head. A queue can be implemented by performing enqueue at the tail and dequeue at the head. |
Q5 |
What is the application of a singly linked list for polynomial representation and addition? |
A5 |
Singly linked lists can be used to represent polynomials, with each node containing a coefficient and an exponent. Addition of polynomials can be performed by adding corresponding terms of the linked lists. |
Q6 |
Explain the concept of a tree and its terminologies. |
A6 |
A tree is a nonlinear data structure composed of nodes connected by edges. Terminologies include root, parent, child, sibling, leaf, depth, height, and level of a tree. |
Q7 |
How can a binary tree be represented? |
A7 |
A binary tree can be represented using linked representations such as a structure with left and right pointers or an array-based representation using indices. |
Q8 |
What are the common tree traversal methods? |
A8 |
Common tree traversal methods include in-order, pre-order, and post-order traversals, which define the order in which the nodes are visited. |
Q9 |
What is a binary search tree (BST)? How does it differ from a regular binary tree? |
A9 |
A binary search tree is a binary tree where the value of each node in the left subtree is less than the value of the node, and the value of each node in the right subtree is greater than the value of the node. A regular binary tree has no specific ordering criteria for its nodes. |
Q10 |
What are the applications of binary trees, such as expression trees, Huffman encoding, and AVL trees? |
A10 |
Binary trees have applications in expression evaluation, Huffman encoding for data compression, and AVL trees for efficient searching and sorting. |