00:00Now let's ask a small question. The question is that we have to print the reverse of an array list.
00:05If I have a list here which is stored in values 1, 2, 3, 4, 5
00:09So in my output window, I should print first 5
00:13After that, I should print 4, 3, 2, 1
00:16So what will I do? Backwards, I will start in a loop
00:20First I will print the stored value in this index
00:23Then I will print the stored value in this index
00:26Then I will store the stored value here and then here
00:29So I have to put a backwards loop
00:31It is exactly the same as I am in an array
00:34So let's write code
00:36What will I do?
00:38I have already made a list
00:40I have already stored elements in 1, 2, 3, 4, 5
00:45Now I am going to print the reverse
00:48So I will put a for loop
00:50I equals list.size-1
00:54Because where will the index be?
00:56The last index is in my list
00:57I have a list.size-1
01:00Now I have to reduce this index
01:02When it is greater than equal to 0
01:04I will do it every time
01:05I will do I minus minus
01:07And every time I am going to print
01:09I am going to print my list.getI
01:13Here I will give you a small space
01:16Here I will give you a small space
01:16And in the last I am going to print
01:18Let's do this
01:18Save and now
01:20Run
01:23So I have output
01:24I have 5, 4, 3, 2 and 1
01:27So I have added the entire list
01:28I have added 7 elements
01:30They are printed in reverse fashion
01:32So in the first element
01:34I have the 0th index
01:36And the last element
01:37I have the array list
01:38.size-1
01:40That is the n-1
01:42That we used in the array
01:44That we used in the array
01:45And in the entire loop
01:46I know how much time complexity
01:48It will be
01:50Big of n
01:51That is the linear time
01:52I have all the elements
01:53In the array
01:53I can see all the elements
01:54I can see all the elements
01:54.size-2