File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -26,10 +26,12 @@ The Arrow(->) operator exists to access the members of the structure or the unio
26
26
int i ;
27
27
if (index >=0 && index < arr -> length )
28
28
{
29
- x = arr -> A [index ]; // first of all take out the element from the particular index you want to del
29
+ x = arr -> A [index ]; // first of all take out the element from the particular index you want to del---------------------> taking 1 unit of time
30
30
for (i = index ;i < arr -> length - 1 ;i ++ ) // shift the element in forward direnction and stop at length -1 so that array can not have any vacant space
31
31
arr -> A [i ]= arr -> A [i + 1 ]; // at the place of a[i] copy the next element i.e a[i+1]
32
- arr -> length -- ;//at last the length will be decreatmented
32
+ arr -> length -- ;//at last the length will be decreatmented ----------------> 1 unit of time -------> so best time is 1+1 =2
33
+
34
+ // min shifting is 0 and max shifting is n ----> Best case time is O(1) -> Worst Case time is ----> O(n)
33
35
return x ;
34
36
}
35
37
return 0 ;
You can’t perform that action at this time.
0 commit comments