0% found this document useful (0 votes)
24 views3 pages

Data 3

The document outlines the time complexities of various algorithms related to arrays, linked lists, stacks, queues, tree traversal, and graph algorithms. Key complexities include O(n) for array insertion at the beginning, O(1) for stack push operations, and O(V + E) for both DFS and BFS in graphs. Additionally, Dijkstra's algorithm has a complexity of O(V^2), while Kruskal's and Prim's algorithms are O(E log V) and O((V + E) log V), respectively.

Uploaded by

Annaya Ch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

Data 3

The document outlines the time complexities of various algorithms related to arrays, linked lists, stacks, queues, tree traversal, and graph algorithms. Key complexities include O(n) for array insertion at the beginning, O(1) for stack push operations, and O(V + E) for both DFS and BFS in graphs. Additionally, Dijkstra's algorithm has a complexity of O(V^2), while Kruskal's and Prim's algorithms are O(E log V) and O((V + E) log V), respectively.

Uploaded by

Annaya Ch
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

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

You might also like