1
00:00:16,039 --> 00:00:24,509
Good morning this is the code we will be discussing
here that is parallel algorithm.
2
00:00:24,509 --> 00:00:38,330
Parallel algorithms which will be designing
on parallel machines before we discuses about
3
00:00:38,330 --> 00:00:44,010
the parallel machine I think that first I
have to tell about that what is sequence algorithms
4
00:00:44,010 --> 00:00:55,250
and sequence data structures what is the other
issues important that there we will discuss
5
00:00:55,250 --> 00:00:56,340
about the parallel algorithms.
6
00:00:56,340 --> 00:01:03,570
Now we look at to the region of the sports
what will we expect from you that you have
7
00:01:03,570 --> 00:01:18,899
knowledge on well this data structure and
algorithm these two works are complete each
8
00:01:18,899 --> 00:01:35,320
other and they are covering a very small component
on the socket engineering life cycle.
9
00:01:35,320 --> 00:01:48,479
Now what is algorithm a algorithm is a step
by step procedure to solve it from them by
10
00:01:48,479 --> 00:01:55,550
automator what is automator is nothing bar
I can give you one example suppose your mother
11
00:01:55,550 --> 00:02:04,950
has told you to bring some idea from the market
ginger and go to the market any of power that
12
00:02:04,950 --> 00:02:11,080
ginger is not available in the market what
are you going to do one way could be possibly
13
00:02:11,080 --> 00:02:16,720
not be purchasing anything and you be coming
back though.
14
00:02:16,720 --> 00:02:28,379
Thinking much and this is that you have acted
as an automation because you do not use your
15
00:02:28,379 --> 00:02:34,409
brain and to think that what would happen
if ginger is not available at home and then
16
00:02:34,409 --> 00:02:40,909
the possibly you will not be able to get your
phone so idea is that you are not using your
17
00:02:40,909 --> 00:02:49,150
brain to solve this problem so you have that
is that an automation is not machine that
18
00:02:49,150 --> 00:02:56,290
is not have any brain okay.
So that it up a definition of algorithm now
19
00:02:56,290 --> 00:03:06,749
what happens in the fight that it must terminate
after some time otherwise I avoid that event
20
00:03:06,749 --> 00:03:15,879
infinite loop and not be able to decide whether
you algorithm gives you the correct thing
21
00:03:15,879 --> 00:03:26,499
after certain amount of time the next problem
is that algorithm must be that is run time
22
00:03:26,499 --> 00:03:34,329
error or something undefined the steps and
third fact everyone should keep it in mind
23
00:03:34,329 --> 00:03:36,189
in the case of algorithm then is it much fun
effective.
24
00:03:36,189 --> 00:03:44,890
What does it mean that if I use pen and pencil
I might be able to solve every step of that
25
00:03:44,890 --> 00:03:51,999
rhythms but if this will happen it may take
you the amount of time to solve the problem
26
00:03:51,999 --> 00:03:59,139
that may be a possible scenario you know another
factor you should keep in mind in the case
27
00:03:59,139 --> 00:04:08,069
of algorithm there must exist some output
otherwise what for you are designing the algorithm
28
00:04:08,069 --> 00:04:14,499
if you are not getting any output or you are
not using any output then does not have any
29
00:04:14,499 --> 00:04:24,560
meaning know this should be input is internal
one or external one know based on that you
30
00:04:24,560 --> 00:04:32,920
can design.
The algorithms now and their own data no it
31
00:04:32,920 --> 00:04:41,350
will so happen that you have different steps
of data and now you are arranging them know
32
00:04:41,350 --> 00:04:49,780
that this structure know in algorithm can
be suitable for one kind of data structure
33
00:04:49,780 --> 00:04:58,680
but we are not we have to fit for another
set of whatever the type of data structure
34
00:04:58,680 --> 00:05:08,870
so slightly live between algorithm and data
structures so basically the meaning of data
35
00:05:08,870 --> 00:05:15,720
structure is that the way you are anything
the data is restricting now there are certain
36
00:05:15,720 --> 00:05:22,810
operations you perform on data structures.
Next one is that you want to read the elements
37
00:05:22,810 --> 00:05:30,730
another one is that you want to modify certain
elements another one that will be like to
38
00:05:30,730 --> 00:05:38,560
insert some elements or delete some elements
from the dataset or you may revert for the
39
00:05:38,560 --> 00:05:45,120
vapor of sudden operations or modification
on some setup some elements of this set of
40
00:05:45,120 --> 00:05:51,720
data right so these are the few operations
we let talked about data structure know in
41
00:05:51,720 --> 00:05:56,030
a it is a structure.
Every type of resistor may be suitable for
42
00:05:56,030 --> 00:05:57,630
some type of operations may not be suitable
for another type of operation so why do you
43
00:05:57,630 --> 00:06:07,060
define that they datas might the programmer
or designer must see about that the type of
44
00:06:07,060 --> 00:06:13,430
questions who like to perform that data depending
on that who designed for one should design
45
00:06:13,430 --> 00:06:21,420
that intersection so once the define then
only you can think about design once you design
46
00:06:21,420 --> 00:06:24,250
the algorithms.
Once you design the algorithms that what are
47
00:06:24,250 --> 00:06:36,070
the factors you should keep it in mind you
that algorithm is correct you cannot justify
48
00:06:36,070 --> 00:06:45,640
they will produce the algorithm and once you
go that word of this correct then the push
49
00:06:45,640 --> 00:06:51,990
is coming they be the algorithm is must be
efficient so what did efficient the efficient
50
00:06:51,990 --> 00:07:03,850
meant that must it should be like you must
be another possibility is that you just taking
51
00:07:03,850 --> 00:07:11,240
this less amount of space.
So that it is not loaded or however now it
52
00:07:11,240 --> 00:07:20,889
is the space problem is not that difficult
because it is easier it is the first wise
53
00:07:20,889 --> 00:07:31,990
the getting memory is not very possible so
we do not consider that space factor much
54
00:07:31,990 --> 00:07:41,810
for designing the algorithm but of course
we compute I place a major role define or
55
00:07:41,810 --> 00:07:43,400
design the algorithm.
56
00:07:43,400 --> 00:07:50,070
There are two types of algorithm complexity
time complexity other one is gonna space complexity
57
00:07:50,070 --> 00:08:16,139
so know how to measure the time foreign algorithms
one way possible way then you design an algorithm
58
00:08:16,139 --> 00:08:23,870
and then implement it on some machines and
then you tell how much time it takes right
59
00:08:23,870 --> 00:08:31,130
so but this is completely missing the part
dependent and you want to compare one with
60
00:08:31,130 --> 00:08:37,140
another algorithms.
And you have to run on the same machine and
61
00:08:37,140 --> 00:08:48,259
then you will able to tell mutually so you
know another Factory is that while if you
62
00:08:48,259 --> 00:08:53,709
tell them by under the big X amount of time
on this then you have to specify the type
63
00:08:53,709 --> 00:09:03,759
of machine you have used which is changing
day by day so that is not a good way of measuring
64
00:09:03,759 --> 00:09:10,310
the time for an algorithm so the next factor
could be that you can tell the number of operations
65
00:09:10,310 --> 00:09:17,410
your company on algorithms and for each.
Category of operations the number of quality
66
00:09:17,410 --> 00:09:23,069
not for each category number of number of
times that operations you have perform right
67
00:09:23,069 --> 00:09:30,029
so number of operations you have used and
or each operator number of times you have
68
00:09:30,029 --> 00:09:37,040
used that you can compute and then we finished
the time because you can tell that for multiplication
69
00:09:37,040 --> 00:09:44,470
takes amount of time for addition Y amount
of time and so on so you can compute the total
70
00:09:44,470 --> 00:09:53,899
amount of time needed for algorithms.
For this algorithms but again this is also
71
00:09:53,899 --> 00:10:00,319
not an easy task to estimate it or to find
out the number of operations you are performing
72
00:10:00,319 --> 00:10:09,160
and algorithms so what is the different way
of distributing the time or another algorithms
73
00:10:09,160 --> 00:10:16,830
one possible thing is the number of you a
find out the that we can find on the data
74
00:10:16,830 --> 00:10:22,759
which are the operations are critical say
for example in the case of some of L numbered
75
00:10:22,759 --> 00:10:27,670
edition is the critical operations.
In the case of matrix multiplication a multiplication
76
00:10:27,670 --> 00:10:34,190
is the critical case some sorting comparison
is the critical operations know the number
77
00:10:34,190 --> 00:10:41,540
of operations what that problem cannot be
defined in terms of output parameters that
78
00:10:41,540 --> 00:10:50,040
is a number of inputs and the number of outputs
you are generating that can be used to estimate
79
00:10:50,040 --> 00:10:58,790
the time complexity for example suppose I
have n elements and you want to find out the
80
00:10:58,790 --> 00:11:00,079
sum of n elements.
81
00:11:00,079 --> 00:11:05,060
Then the operation number of positions or
the number of additions you will be using
82
00:11:05,060 --> 00:11:08,769
is a function of the n function can you estimate
the number of editions we need of innovation
83
00:11:08,769 --> 00:11:19,939
to make the number of with the number of additions
you need to find the sum of n elements yes
84
00:11:19,939 --> 00:11:30,649
the number is n minus 1 nobody then 10 minus
1 it is since you need to find the sum of
85
00:11:30,649 --> 00:11:38,410
N minus one so this is depended on algorithm
similarly the case with multiplication so
86
00:11:38,410 --> 00:11:44,660
there is the classical algorithm this is here
two types of operations use one is plus another.
87
00:11:44,660 --> 00:12:11,219
Classical algorithm could be for I plus 1
ton or j = 1 to n cij = 0 for a= 1 to n cij
88
00:12:11,219 --> 00:12:18,139
= kij star bkj plus c I j right this is the
simple classical algorithm formats this is
89
00:12:18,139 --> 00:12:19,660
multiplications.
And you absorb here two types we can use class
90
00:12:19,660 --> 00:12:28,709
another is multiplications and now you now
the multiplication now you know the Cartesian
91
00:12:28,709 --> 00:12:37,370
reason is the cost fear market takes more
time than addition so the critical opportunity
92
00:12:37,370 --> 00:12:48,490
here is multiplication you observe that if
I see whole algorithm that who assignments
93
00:12:48,490 --> 00:12:50,699
to who assignments.
94
00:12:50,699 --> 00:13:08,259
The two assignments is one addition and one
multiplication besides this loading of these
95
00:13:08,259 --> 00:13:16,040
measurements for assignment form or these
all rows okay and here this multi fiction
96
00:13:16,040 --> 00:13:24,480
is up with your participation in the number
of number of multiplications.
97
00:13:24,480 --> 00:13:39,000
You should see you need number of multiplications
you need to fight the municipality to conclude
98
00:13:39,000 --> 00:13:52,200
about complications this one which is n3 okay
so here you observe the time complexity.
99
00:13:52,200 --> 00:14:00,300
So whether the type of the exhibition using
the input output parameters now here there
100
00:14:00,300 --> 00:14:12,079
you will find the worst case possible in the
best case possible for example to find to
101
00:14:12,079 --> 00:14:23,420
sort n elements you find sometimes worst case
and this the case we want to estimate what
102
00:14:23,420 --> 00:14:24,420
case and the best case.
103
00:14:24,420 --> 00:14:40,040
O an big OH this is omega notation this possible
that is the upper bound this is lower bound
104
00:14:40,040 --> 00:15:20,529
then and what is that data rotation as know
as theta notation and the small oh which we
105
00:15:20,529 --> 00:15:24,110
use worst case.
106
00:15:24,110 --> 00:16:13,509
Let if f a function of f let g n be also function
of n f n o of g n if exists that constancy
107
00:16:13,509 --> 00:16:44,939
and like that n not such that n and nor that
such f n less than equal to g n for all n
108
00:16:44,939 --> 00:16:49,509
and n0 a bad little equal to C times G.
109
00:16:49,509 --> 00:17:08,579
So for example you have this is a polynomial
of degree set n an x n plus an-1 xn-1 plus
110
00:17:08,579 --> 00:17:18,079
g1xplusa0 so if it is a polynomial of degree
n what does it mean that yeah this is the
111
00:17:18,079 --> 00:17:26,670
leading coefficient is 0 but suppose I want
to find out the what is that complex well
112
00:17:26,670 --> 00:17:39,620
what is must complexity okay.
113
00:17:39,620 --> 00:18:03,981
For I = 1 to n for j = 1 to I and you suppose
I want to compute the complex of this if they
114
00:18:03,981 --> 00:18:09,070
are otherwise pure optics was this complexity
so you will be writing the summation over
115
00:18:09,070 --> 00:18:41,919
I equals to 2 so this Oh but if it is the
case to circulate I sequel and square no but
116
00:18:41,919 --> 00:19:53,450
what is I and c is constant so this is are
summation over that is 1 to n c to I c1 n
117
00:19:53,450 --> 00:20:04,550
plus 1by 2 okay.
or what they go one N equals 1 is 1 and N
118
00:20:04,550 --> 00:20:18,100
equals to 2 that is 3 and so on so the I can
be in a lie in a night square yes you can
119
00:20:18,100 --> 00:20:31,450
write because I can always write equal to
this I can always write summation C x n plus
120
00:20:31,450 --> 00:20:32,770
1 to be in Square this I can write these in
cube plus C 2 square with no issue that c
121
00:20:32,770 --> 00:20:34,100
plus b c d in queue and this is always right.
122
00:20:34,100 --> 00:20:46,610
You can tell me can I write this n3 yes answer
is yes you can write because I can write summation
123
00:20:46,610 --> 00:21:12,650
and summation and 1 I= 1 to 10 a =1 equal
c n2 s n3 plus cn2 where c plus d n3 this
124
00:21:12,650 --> 00:21:35,910
all is proof or any one and this is l1 n3
equal to n3 not seeing you observed that this
125
00:21:35,910 --> 00:21:45,460
grammar I can explain of the properly q but
problem is somewhere else because I have to
126
00:21:45,460 --> 00:21:54,170
sell my algorithm and replicate so you see
that this is as to the to form nor possible
127
00:21:54,170 --> 00:22:46,780
values you are possible to expand now I have
a small question for you.
128
00:22:46,780 --> 00:22:58,830
And the same function b n with existing equal
to a and b are the constants suppose there
129
00:22:58,830 --> 00:23:29,470
is a constant can I write this one log b n
equal to c log b n and c log b a and log a
130
00:23:29,470 --> 00:23:53,090
n so this is nothing but d log a n l the complexity
we mention because does not have much meaning
131
00:23:53,090 --> 00:24:07,530
does already meaning to define possible that
know think about the other symbol which is
132
00:24:07,530 --> 00:24:18,690
do not beat Omega symbols here is the stocking
of the lower column.
133
00:24:18,690 --> 00:24:24,150
Which means that means that you have g n are
the two function on then and you have the
134
00:24:24,150 --> 00:25:01,360
two constants d and n1 and here is if n equal
to d g n equal to n1 and if omega g n okay
135
00:25:01,360 --> 00:25:09,760
the little details that you if I tell you
a little bit of GN that means they can achieve
136
00:25:09,760 --> 00:25:17,780
the lower bound with a constant factor within
a constant factors now theta is another notation
137
00:25:17,780 --> 00:26:10,270
we use where you can have the two functions
if n g n and h n if fn theta g n if d g n
138
00:26:10,270 --> 00:26:18,780
right.
Which means f n is achieved both lower bound
139
00:26:18,780 --> 00:26:32,500
and upper bound of them factors so we now
there is another notation of you the center
140
00:26:32,500 --> 00:26:50,840
in rotation small o.
141
00:26:50,840 --> 00:27:05,370
That is the f n if it is a asymptotic proof
that is except to g n yeah that means n to
142
00:27:05,370 --> 00:27:23,960
infinity that fn by g n =1 right so we tell
if any deception yeah if F and G so this are
143
00:27:23,960 --> 00:27:28,650
the terms.
We use for sequential algorithms for evolving
144
00:27:28,650 --> 00:27:40,170
these sequential algorithms okay now we look
at the discuss about the data structures you
145
00:27:40,170 --> 00:27:53,851
have got something under intuitive course
and first thing is that you have done a simple
146
00:27:53,851 --> 00:27:54,851
data structure w should know that array.
147
00:27:54,851 --> 00:28:00,380
Now once you have an elements you tell they
have priority what is the number of elements
148
00:28:00,380 --> 00:28:22,900
in there right so of and so the first part
is that each is known to you the number of
149
00:28:22,900 --> 00:28:29,720
our products the number of elements and the
first point is known to you is the number
150
00:28:29,720 --> 00:28:31,150
of you an clear priority in a way there is
a major disadvantage now the second thing
151
00:28:31,150 --> 00:28:38,110
is then let us try to let us try to perform
certain operations on these set.
152
00:28:38,110 --> 00:28:47,390
Suppose I want to read the elements in the
la so you need to read all the elements one
153
00:28:47,390 --> 00:28:56,930
by one and that takes four of the amount for
the end time okay now this is array elements
154
00:28:56,930 --> 00:29:07,640
are right then at any moment you can fit the
8 element in read one time so really very
155
00:29:07,640 --> 00:29:28,630
already take once it is read reading the highest
element sometimes the next one is that suppose
156
00:29:28,630 --> 00:29:35,520
I want to insert and element in the array.
157
00:29:35,520 --> 00:29:43,330
So this is the insertion with task in the
head suppose I want to search element is here
158
00:29:43,330 --> 00:29:51,240
what you have to do you have to hit third
place for this element so you know to get
159
00:29:51,240 --> 00:30:03,930
that all the elements has to be shifted by
one house towards your line so in the worst
160
00:30:03,930 --> 00:30:22,940
case in such case so now suppose I want to
insert a element is here rules I have addition
161
00:30:22,940 --> 00:30:25,210
to sufficient to these sign this is the best
part.
162
00:30:25,210 --> 00:30:37,960
Now we think about the deletion what happen
suppose I can delete this value there resident
163
00:30:37,960 --> 00:30:48,470
bring third element ids here this element
here and so on so there is a occupy deletion
164
00:30:48,470 --> 00:30:58,140
n time right if there is a best possible case
suppose I have believe the last element amount
165
00:30:58,140 --> 00:31:10,370
of that time suppose I want to define the
idea filament of the air it was time to yes
166
00:31:10,370 --> 00:31:14,460
it takes order 1 because I will just go to
I element and random existence can easily
167
00:31:14,460 --> 00:31:19,390
replace.
What kind of time element and to take these
168
00:31:19,390 --> 00:31:29,120
onetime and so these are the major steps or
major opposition what common is data on is
169
00:31:29,120 --> 00:31:40,800
this data okay now a simple question for you
we know what is the transpose of a matrix
170
00:31:40,800 --> 00:31:46,140
okay just of the back faces very safe full
operation goes but it is not while I try to
171
00:31:46,140 --> 00:31:47,620
write another task.
172
00:31:47,620 --> 00:31:58,310
Force of matrix is nothing but that is you
have Aij has to be just change the A ji so
173
00:31:58,310 --> 00:32:06,260
that is the operations you are going too far,
it looks then is a simple touches between
174
00:32:06,260 --> 00:32:13,210
these two elements okay but if I tell you
the right hand has been apart obtaining the
175
00:32:13,210 --> 00:32:20,180
transpose of a matrix you observe that it
has work that easy let us can you tell me
176
00:32:20,180 --> 00:32:22,140
what I could write,
177
00:32:22,140 --> 00:32:48,360
S for I equal to 1 to N for j = - to N temp
= a i j ; a I j = a j i ;and then a j i = temp
178
00:32:48,360 --> 00:33:01,970
; so if it is a case can you tell me what
I should write here one let us see what happens
179
00:33:01,970 --> 00:33:13,070
by right one unwilling to get the test possible
metrics on Sonny's know it will give you the
180
00:33:13,070 --> 00:33:18,580
same matrix again this is because of the fact
that S or Y you will be first signs,
181
00:33:18,580 --> 00:33:27,470
You will index will be a j i. A when I equals
to J and equals to Y you find that a I index
182
00:33:27,470 --> 00:33:40,150
will a j i you try at home and you see that
two types index is and another whole example
183
00:33:40,150 --> 00:33:49,740
is there you get that the value and you see
that. So what I should write here one can
184
00:33:49,740 --> 00:34:02,320
write I to N in that case yes we will get
one and you get the transform of the matrix
185
00:34:02,320 --> 00:34:09,480
yes this is one touch it yes this is there
is one problem you observe that pyrite I to
186
00:34:09,480 --> 00:34:15,790
N by issue is the diagonal element would change
again and again but there is no question of
187
00:34:15,790 --> 00:34:19,649
or there is no need of interchanging even
of the matrix.
188
00:34:19,649 --> 00:34:30,730
So one can write I + 1 2 right now suppose
I want to obtain the complexity of this algorithm
189
00:34:30,730 --> 00:34:32,320
then you can find out that,
190
00:34:32,320 --> 00:34:34,410
I= 1to N = i+1 and this is constant time because
constant time it is. And you can write function
191
00:34:34,410 --> 00:34:36,830
form is = N C capture N - I which I can write
C N square - C, N x N+1/2. And which is C
192
00:34:36,830 --> 00:35:14,450
N square = 0 x N square. So what do you remember
the Testaments of the man chase takes all
193
00:35:14,450 --> 00:35:27,450
it is the minimum requirement this is also
now the linked you has been to your through
194
00:35:27,450 --> 00:35:33,010
is link liet.
195
00:35:33,010 --> 00:35:44,770
This data structure you will forward to a
tour now in the latest one is single liet
196
00:35:44,770 --> 00:36:16,000
next one double liet and then generalization
linked list. Well you know discuss of the
197
00:36:16,000 --> 00:36:18,400
single in list so we have,
198
00:36:18,400 --> 00:36:26,500
Them and more is tool having the list to fill
one is know has didapper then didapper another
199
00:36:26,500 --> 00:36:55,200
one of these linked. The link is and the linked
point to the next two okay and the starting
200
00:36:55,200 --> 00:37:07,220
load is named is a name of the link list in
the here If I have to part for the link list
201
00:37:07,220 --> 00:37:09,790
let us what will happen read all the data
so you read one by one. This takes order in
202
00:37:09,790 --> 00:37:16,400
an order in a number of times. Now suppose
I read all the data so you complete one by
203
00:37:16,400 --> 00:37:24,350
one which takes order in a numbers of time.
Now suppose I want to get the higher the element
204
00:37:24,350 --> 00:37:30,540
of the link list then here could travel of
the beginning to the higher position which
205
00:37:30,540 --> 00:37:43,510
takes 0(1). So basically you need for an N
time in the wreckage to nutria. I want to
206
00:37:43,510 --> 00:37:50,570
verify I want to modify the anything even
telling me then I have to go up quiet position
207
00:37:50,570 --> 00:38:01,090
and then modify them which takes order items
now what happens the insertion and deletion
208
00:38:01,090 --> 00:38:09,480
if I do not know way to which one to be deleted
or I do I know that position and then perform
209
00:38:09,480 --> 00:38:19,310
the addition of functions.
So it takes right hand and then you perform
210
00:38:19,310 --> 00:38:25,540
the operations similarly if I have to insert
some rows here so here you have to reach up
211
00:38:25,540 --> 00:38:34,140
to this one and then we will right so let
us say show that this forum right can be still
212
00:38:34,140 --> 00:38:42,630
there plus the insertion or deletion time
to be considered right now let us see suppose
213
00:38:42,630 --> 00:38:54,370
I want to insert a node donate what I do a
write of to this by some means for some time
214
00:38:54,370 --> 00:39:04,490
and then I will get into get it no visitors
and then if I leave this one first by leaving
215
00:39:04,490 --> 00:39:11,170
this one fault then I do think for which about
this one so what happened I have refined this
216
00:39:11,170 --> 00:39:18,180
one and then this.
217
00:39:18,180 --> 00:39:35,670
One the next one is so suppose I want to delete
the node doctrines how can I believe the note
218
00:39:35,670 --> 00:39:41,940
after that you will have to delete the node
of today what I can do I could just turn the
219
00:39:41,940 --> 00:40:04,600
page to them because the next to nothing right
become X will be point to the link of X of
220
00:40:04,600 --> 00:40:13,630
suppose I want to delete this pool how can
I do connectivity in constant if I can do
221
00:40:13,630 --> 00:40:25,650
that then we can I believe this yes certificate
understand oh you can do it say instead of
222
00:40:25,650 --> 00:40:31,010
beating this code because I know I cannot
go back so one way it could be although it
223
00:40:31,010 --> 00:40:38,030
could be that I copy this data here.
I copy this data here and then give admissible
224
00:40:38,030 --> 00:40:46,100
in that case this takes of it takes for some
time and takes constant time so you can delete
225
00:40:46,100 --> 00:40:58,530
this node the posted amount of time now think
about the problem you face in the single linkage
226
00:40:58,530 --> 00:41:04,250
is the playing back what is very defeated
will backward is very difficult because your
227
00:41:04,250 --> 00:41:13,140
part from the beginning so you do not get
rid of that getting upset.
228
00:41:13,140 --> 00:41:27,890
We define now doubling it is that because
one is left link another one is right and
229
00:41:27,890 --> 00:41:50,000
this is the data. What it does that going
backward or forward will not be problem in
230
00:41:50,000 --> 00:42:02,740
the case of copying the data structure you
have done thLink back and say one example
231
00:42:02,740 --> 00:42:17,720
could be the in the library we have seen the
books then the find out bring some books beginning
232
00:42:17,720 --> 00:42:35,950
parts in the linker. You are from that stack
of say for example in the dining area of your
233
00:42:35,950 --> 00:42:47,950
footstep so why do you hid in the dining hall
you will find that another one and so on and
234
00:42:47,950 --> 00:42:53,690
then you ever write if you want to take your
food so you will be taking that bit from the
235
00:42:53,690 --> 00:43:09,690
top worst man of that planning he got set
up Thanks any new boutique on the copper so
236
00:43:09,690 --> 00:43:23,600
that is bonus that is an example of staff
okay but the example that you is very simple
237
00:43:23,600 --> 00:43:28,090
you stand in that movie home to get that ticket
the front person yes that we can engage and
238
00:43:28,090 --> 00:43:36,180
the person joins to paint the ticket he stands
at the end of that here. No we do not understand
239
00:43:36,180 --> 00:43:38,310
what happened now.
240
00:43:38,310 --> 00:43:50,850
Suppose I want to insert an element in the
case of stack. Suppose I want to delete it
241
00:43:50,850 --> 00:43:58,109
anyway there are a shock also from that talk
and every time it takes a constant amount
242
00:43:58,109 --> 00:44:04,500
of time so in the case of that insertion and
deletion from one end in the case of Queue
243
00:44:04,500 --> 00:44:33,970
this is so few sessions we wanted and another
that is that definition of Queue. See an example
244
00:44:33,970 --> 00:44:39,330
for this Stack could be there subliming colleague
.
245
00:44:39,330 --> 00:45:01,030
So you have for a main program and you have
a routine here you are fully sub routine A
246
00:45:01,030 --> 00:45:31,210
and then sub routine B and sub routine C and
see is calling so here is the return statement,
247
00:45:31,210 --> 00:45:51,080
return statement here and end. You have so
yeah which is you know stack from the stack
248
00:45:51,080 --> 00:46:06,450
so he comes here then you get yes compared
to that this is S so obvious and it comes
249
00:46:06,450 --> 00:46:17,340
so that is the one example where that leaves
you know views or you know the top three.
250
00:46:17,340 --> 00:46:23,450
What is checking the next topology will be
discussing finally Binary Tree. T tree rotate
251
00:46:23,450 --> 00:46:42,070
N o, N is at least and one node is known as
the root of the tree this is the is special
252
00:46:42,070 --> 00:47:13,369
dedicated to root of the tree and you have
the remaining N - 1 then connected they are
253
00:47:13,369 --> 00:48:04,369
connected to the root R and also this n over
form a this sub trees this end goes forms
254
00:48:04,369 --> 00:48:41,851
X form B sub trees. So tree is rusticating
you have a report R you look at the R,
255
00:48:41,851 --> 00:48:47,440
You so if I remove this that you cannot eat
the joint sub trees if I remove this you get
256
00:48:47,440 --> 00:48:55,490
to gain some number of sub trees and so on
only condition is that that will be at least
257
00:48:55,490 --> 00:49:08,381
one node in the case of binary empty finality
is an empty file it is also violating that
258
00:49:08,381 --> 00:49:18,530
is nothing in the so that you can define for
the final virology otherwise especially notification
259
00:49:18,530 --> 00:49:44,440
of root and because at post so which one is
the left sub-tree another one right sub-tree
260
00:49:44,440 --> 00:50:10,150
depths of peace and the right side and let
us of trees and the rights of sub trees.
261
00:50:10,150 --> 00:50:32,780
Then would be collect what is heap? Heap is
complete banner tree. What is complete by
262
00:50:32,780 --> 00:50:49,080
a tree means that it is cone up to the last
part of one level it is pool one level and
263
00:50:49,080 --> 00:51:03,980
the last level it is pool form left to tight
okay. So heap complete banner tree of level
264
00:51:03,980 --> 00:51:20,191
and it is certain one for tree in the case
of we need if it is the minimum element or
265
00:51:20,191 --> 00:51:25,780
this minimum element is the put that element
of left and right join.
266
00:51:25,780 --> 00:51:39,330
And also this is left side the heap and right
side of heap also be need okay. So this is
267
00:51:39,330 --> 00:51:59,160
the complete binary tree and this code can
call the minimum element complete to right
268
00:51:59,160 --> 00:52:10,200
element and left of element solved this.
269
00:52:10,200 --> 00:52:30,140
We define G = V,E, V is the set of artists
and E is the set of artists suppose you have
270
00:52:30,140 --> 00:53:19,400
V1, pointed to the V2 to the V n and you have
ages G1, G2 and yeah in between G sign to
271
00:53:19,400 --> 00:53:34,240
V k, V l right.
272
00:53:34,240 --> 00:53:45,960
This you can say V1, V2, V3, V4, V5, V6 like
it is also tree. Tree is number of areas you
273
00:53:45,960 --> 00:54:00,310
have the number of edges n-1 Okay. Because
they connected a sec and if I had this always
274
00:54:00,310 --> 00:54:13,420
drop free and just we are defining so they
like this nothing offered is on a Smartphone
275
00:54:13,420 --> 00:54:29,780
now let us understand a simple problem and
see how we can solve so skill appear do you
276
00:54:29,780 --> 00:54:40,000
remember that how to find out the minimum
of n elements suppose you have N elements.
277
00:54:40,000 --> 00:54:48,130
And I will point out that will move this n
elements one possible way that you have you
278
00:54:48,130 --> 00:54:57,880
want it we initially you find we move is a
1 then minimum is compared. With a - you find
279
00:54:57,880 --> 00:55:04,640
me - is smaller than me then mean is different
by a - and then you compare again with a 3
280
00:55:04,640 --> 00:55:12,359
and if you find that a 3 is it up and we do
not credit they go for the next one and so
281
00:55:12,359 --> 00:55:21,050
on so in that process like to find out the
minimum penalty now the problem is here.
282
00:55:21,050 --> 00:55:28,750
Suppose instead of finding the minimum of
n elements I am interested to find out the
283
00:55:28,750 --> 00:55:47,270
second. So one possible way is very first
of you find the minimum now you have the remaining
284
00:55:47,270 --> 00:55:57,080
n -1 elements hey here you find the minimum
let into your second minimum.
285
00:55:57,080 --> 00:56:02,510
So if the for the first case you give n - 1
comparisons say many times we give n -2 competitors
286
00:56:02,510 --> 00:56:13,190
so you care 2n - 3 operators to find our second
but is it the best way so let us consider
287
00:56:13,190 --> 00:56:29,400
this problem that finding the second minimum
confidence and our target is to find out whether
288
00:56:29,400 --> 00:56:39,530
this is the best possible way of finding the
second now let us consider the another for
289
00:56:39,530 --> 00:56:48,859
suppose I am interested to find out minimum
and maximum no one way possibly that you find
290
00:56:48,859 --> 00:56:51,140
the minimum of this again so for simplicity
for simplicity little issue.
291
00:56:51,140 --> 00:56:59,119
So what about the other one so if I look into
this programme you get a1,a2,a3,a4,a5 a6,a7,
292
00:56:59,119 --> 00:57:00,119
a8.
293
00:57:00,119 --> 00:57:12,640
That there are eight teams but are participating
1k and we want to introduce the corner among
294
00:57:12,640 --> 00:57:39,120
days to find out who is the winner right so
in order to do that what we do we divide into
295
00:57:39,120 --> 00:57:49,750
four groups each group consists of two teams
and these two teams of each group play each
296
00:57:49,750 --> 00:58:03,100
other and one of them will be declared as
we got and now in order to see the winner
297
00:58:03,100 --> 00:58:26,500
of this so this form will be divided into
two groups and the winner is proceeded to
298
00:58:26,500 --> 00:58:53,930
find out to find out the winner we are gonna
move the same things by not know replace winner
299
00:58:53,930 --> 00:59:07,840
by place occupied.
Me what happened so this gives you the minimum
300
00:59:07,840 --> 00:59:25,520
of this now minimum these two images they
are a minimum of these two elements will be
301
00:59:25,520 --> 00:59:40,900
here and minimum of this which is the minimum
of this a degree so you observe the number
302
00:59:40,900 --> 00:59:53,950
of comparisons we have used here 1 2 3 4 5
6 7 to find that meaning agree now you know
303
00:59:53,950 --> 01:00:06,010
the point of the maximum of these you observe
that vacuum cannot be any one of them because
304
01:00:06,010 --> 01:00:12,160
they are the minimum so Basin would be one
of these four elements okay.
305
01:00:12,160 --> 01:00:28,640
One of the four elements means that you have
to find out the maximum of this four elements
306
01:00:28,640 --> 01:00:44,570
the four elements nothing but dead by two
elements and finding the maximum of this politics
307
01:00:44,570 --> 01:01:18,480
in two minus one so the number of comparisons
need to find the so it just must fit us that
308
01:01:18,480 --> 01:01:45,310
much better now what about what about the
other one the findings down so if I look into
309
01:01:45,310 --> 01:02:07,700
this problem on you have suppose so to find
the second video which are the probable because
310
01:02:07,700 --> 01:02:14,490
this is the winner of a minimum of this for
a point this is so you have that many possible
311
01:02:14,490 --> 01:02:15,690
candidates all right among that you have to
find me.
312
01:02:15,690 --> 01:02:24,180
So this you observe that every I gives one
in every level to get one for this level this
313
01:02:24,180 --> 01:02:41,230
one or this level this one at this level the
height of this tree is login find the minimum
314
01:02:41,230 --> 01:03:04,750
you get the N minus 1 the height of the tree
is log n minus 1 to find the minimum I love
315
01:03:04,750 --> 01:03:25,829
the so second minimum but then one to find
that you have to buy so n + you get - 2 -log
316
01:03:25,829 --> 01:03:41,630
N - 2 + log n - 3 and so you find that suppose
I have to find out the first minimum second.
317
01:03:41,630 --> 01:03:57,690
When you move to n minimums so this becomes
which is basically is nothing but n which
318
01:03:57,690 --> 01:04:14,880
takes that basically we're making the sorting
of n elements little stop here in the next
319
01:04:14,880 --> 01:04:18,369
class you will be discussing a different Parallel
Algorithm rule for equation. And then the
320
01:04:18,369 --> 01:04:35,619
third class will study about the Parallel
Algorithm what are the things to cover the
321
01:04:35,619 --> 01:04:40,660
definition okay thanks.