1. What are the various operations that can be performed on different Data Structures?
Basic Operations performed on Data Structures are:
- Insertion − Add a new data item in the data structure.
- Deletion − Delete an existing data item from the data structure.
- Traversal − Access each data item exactly once so that it can be processed.
- Searching − Find out the location of the data item if it exists in the data structure
- Sorting − Arranging the data items in some order.
2. Difference between stack and queue?
|1. It is called LIFO which stands for Last in first out as stack uses this property.
2. Elements inserted first will be accessed last as it has only one open end.
3. Recent element in the stack is accessed using the value of top which points to the topmost element of the stack
4.For inserting an element push() function is used.
5.for deleting an element pop() function is used.
6.example is plates placed one above the other.
|1. It is called FIFO which stands for First in first out as stack uses this property.
2.element inserted first will be served first
3.it has two open ends called as rear end and front end
4.element is deleted using pop() function from the front end of the queue.
5.element is inserted using push() function from the rear end of the queue.
6.example is a queue for the bus.
3. What are infix, prefix, and postfix notations?
Infix, Postfix, and Prefix notations are the most common ways of writing expressions.
- Infix notation is commonly used in arithmetic formula or statements, the operators are written in-between their operands. Example: (A+B)
- In Prefix notation operators are used before their operands. For example, to add 3 and 4, instead of writing 3 + 4 which is infix expression, prefix expression will be + 3 4.
- In Postfix notation operators are used after their operands. For example, to add 3 and 4, instead of writing 3 +
- 4 which is infix expression, postfix expression will be 3 4 +. The order of evaluation of operators is always left-to-right, and brackets cannot be used to change this order.
4. What are the linked lists and mention their types?
A linked list is a sequence of data structures, which are connected together via links.
The various types of linked lists are-
- Simple Linked List − In this type of linked list, the Item navigation is forward only.
- Doubly Linked List − In this type of linked list, the Items can be navigated forward and backward.
- Circular Linked List − In this type of linked list the last item contains a link of the first element as next and the first element has a link to the last element as previously.
5. How to check if a given binary tree is BST or not?
We needs to first find out the inorder traversal. If the inorder traversal of a binary tree is sorted, then the binary tree is BST.