Data Structure Interview Questions
What are the different types of linked list?
Singly Linked List : every node stores address or reference of next node in list and the last node has next address as NULL. Doubly Linked List : One of the reference points to the next node and one to the previous node. Circular Linked List : all nodes are connected to form a circle, no NULL at the end, can be a singly circular linked list or doubly circular linked list.
What is Stack and where it can be used?
Stack is a linear data structure which the order LIFO(Last In First Out) for accessing elements. Basic operations of stack are : Push, Pop , Peek
What is a Data Structure?
A data structure is a way of organizing the data so that the data can be used efficiently.
What is a Linked List ?
A linked list is a linear data structure where each element is a separate object. Each node of a list is contains the data and a reference to the next node.
Can doubly linked be implemented using a single pointer variable in every node?
Doubly linked list can be implemented using a single pointer.
How to check if a given Binary Tree is BST or not?
If inorder traversal of a binary tree is sorted, then the binary tree is BST.
What are Infix, prefix, Postfix notations?
Infix notation: X + Y Operators are written in-between their operands. Postfix notation: X Y + Operators are written after their operands. Prefix notation: + X Y Operators are written before their operands.
What are the various operations that can be performed on different Data Structures?
Insertion, Deletion, Traversal, Searching, Sorting
What are linear and non linear data Structures?
Linear: A data structure is said to be linear if its elements form a sequence or a linear list. Examples: Array. Linked List, Stacks and Queues Non-Linear: A data structure is said to be non-linear if traversal of nodes is nonlinear in nature. Example: Graph and Trees.
What is a Queue, how it is different from stack and how is it implemented?
Queue is a linear structure which follows the order is First In First Out (FIFO) to access elements queue is FIFO while stack is LIFO implemented using Arrays or Linked Lists
Which data structures are used for BFS and DFS of a graph?
Queue is used for BFS Stack is used for DFS. DFS can also be implemented using recursion
How is an Array different from a Linked List
array size is fixed, Linked Lists size are Dynamic insertion and deletion is easily done in Linked Lists, but for arrays is expensive No Random access in Linked List link lists need Extra memory space for a pointer Arrays have better cache locality