Question no 1
Mention the time complexity of all the algorithms that are
include in course?
1-Arrays
a-Insertion at the Beginning
Adding an element to beginning of array is O(n)
b-Insertion at the End
O (1) accurately describes inserting at the end of the array.
c-Insertion at the Specific index
if you're inserting into the middle of an array, complexity for insertion in that
case is O(n)
d-Delete at the Beginning
This is also O(n) so the total complexity
d-Delete at the End
Time complexity deletion of last element is o(1)
e-Insertion at the Specific index
The time complexity will be O(N - 1).
f-Traversal of array
complexity of this algorithm is O(n).
g-Search of array
O(1) for each variable
2-Linked-List
OPERATIONS Time Complexity
Insertion at the Beginning O(1)
Insertion at the End O(N)
Insertion at the Specific O(n)
Index
Delete at the Beginning s O(n)
Delete at the End O(1).
Delete at the Specific index O(N)
Traversal O(√N)
3-Stack
OPERATIONS Time Complexity
Push O(1)
POP O(1)
Top O(1)
Search O(n)
4-Queue
OPERATIONS Time Complexity
Enqueue O(1)
Dequeue O(1)
5-Tree Traversal
OPERATIONS Time Complexity
In-order O(n)
Pre-order O(n + m)
Post-order O(N)
6-Graphs
OPERATIONS Time Complexity
DFS O(V + E)
BFS O(V + E)
7-dijkstra algorithm
Dijkstra's algorithm is O ( V 2 ) O(V^2) O(V2) where V is the number of
vertices in the graph.
8- Kruskal algorithm
Kruskal's algorithm's time complexity is O(E log V), V being the number of
vertices
9- prim's algorithm
The time complexity of the Prim's Algorithm is O ( ( V + E ) l o g
V ) because each vertex