Data Structures
Data Structures
A data structure is a specialized format for organizing, processing, retrieving and storing data.
The size of the array must be specified at the time Size of a Linked list grows/shrinks as and when new
of array declaration/initialization. elements are inserted/deleted.
Data elements are stored in contiguous locations in New elements can be stored anywhere and the
memory. reference is created with the help of a pointer.
Memory is allocated during the compile-time (Static Memory is allocated during the run-time (Dynamic
memory allocation). memory allocation).
10. What do you mean by single and double-ended data structure? Give example.
The single-ended queue is a normal queue where insertion takes place at the FRONT of the queue
and deletion takes place at the END of the queue. Ex: CPU scheduling.
In a Double Ended Queue, insertion and deletion operations can be done at both FRONT and END of
the queue. Ex: Palindrome checker.
Stack Queue
The stack is based on LIFO(Last In First Out) The queue is based on FIFO(First In First Out)
principle principle
Insertion Operation is called Push Operation Insertion Operation is called Enqueue Operation
Deletion Operation is called Pop Operation Deletion Operation is called Dequeue Operation
Push and Pop Operation takes place from one Enqueue and Dequeue Operation takes place
end of the stack from a different end of the stack.
Only one pointer is used for performing Two pointers are required to operate.
operations
12. What are some applications of a stack?
a) Evaluation of Arithmetic Expressions
b) Backtracking
c) Reverse a Data
d) Processing Function Calls
13. What is the time complexity of push and pop operation in a stack?
Big O(1)
18. Which data structure can be used both as stack and queue at the same time?
Linear Data Structure.
26. If i is the index of the parent node then what is the index of the left child and right child of it in an
array?
28. Using which data structure you can minimize the search complexity in Linked List?
29. What is the worst-case time complexity of searching a node in a Binary Search Tree?
O(n).
48. Name some inbuilt data structures that are inbuilt in Java?
● Array.
● Linked List.
● Stack.
● Queue.
● Binary Tree.
● Binary Search Tree.
● Heap.
● Hashing.