1
00:00:20,160 --> 00:00:28,880
So today we will be discussing on Bitonic
sorting network.
2
00:00:28,880 --> 00:00:45,200
Now same as we did in the earlier case here
also will be first defining what is Bitonic
3
00:00:45,200 --> 00:01:18,280
sequence, Third will be discussing by Bitonic
Marge, then we will be discussing by Bitonic
4
00:01:18,280 --> 00:01:33,429
Merging Network finally we will have by Bitonic
sorting Network.
5
00:01:33,429 --> 00:02:05,810
So if you want it to be a sequence A= { a
1, a 2 ,a 3 , A n A 2 n} and be a sequence
6
00:02:05,810 --> 00:02:49,270
if there exists Bitonic sequence if a j, or
such that either Q1 = a2 a2n or by some cyclic
7
00:02:49,270 --> 00:03:44,490
shifts it satisfies . Like the sequence is
going by to Bitonic sequence either a 1 = to
8
00:03:44,490 --> 00:03:58,770
8 2 = to a and = to A J = to A + 1 to = F
2 N or by some cyclic shifts some cyclic shifts
9
00:03:58,770 --> 00:04:02,530
it achieved this one.
10
00:04:02,530 --> 00:04:18,600
Now for example a sorted sequence is a bionic
sequence say why it is so 1, 2. 3, 4, So by
11
00:04:18,600 --> 00:04:36,490
cyclic shift you can get by cyclic shift you
can get 2,3,4,1 which satisfies your hops.
12
00:04:36,490 --> 00:04:49,150
for similarly that 4,3,2,1 is also a Bitonic
sequence right this operator even though I
13
00:04:49,150 --> 00:04:57,290
have written = to it can be = to also by cyclic
shift you can show that one another thing
14
00:04:57,290 --> 00:05:18,620
what I can tell a sequence is also at this
stage no yes or no yes but if it is clear.
15
00:05:18,620 --> 00:06:00,390
You can define Theorem let create will be
a battle it is offensive to be elements define
16
00:06:00,390 --> 00:07:21,080
two sequences be D and E as where Di is minimum
of Ai, A n + I, Ai is maximum of Ai and N+I.
17
00:07:21,080 --> 00:07:51,990
Then D, E is Bionic sequences maximum of D
is = minimum of E. So maximum elements of
18
00:07:51,990 --> 00:08:00,910
E equals to minimum of E the stepwise are
you cleared. The water we have obtained we
19
00:08:00,910 --> 00:08:09,400
have trended on the two sequence DNE these
obtain the is element of D is obtained by
20
00:08:09,400 --> 00:08:16,120
taking the minimum of these two elements and
E is optimal taking the maximum of these two
21
00:08:16,120 --> 00:08:21,660
elements.
The D is a part of a sequence he is also part
22
00:08:21,660 --> 00:08:31,850
in a sequence and maximum B is = equals to
minimum of we know how in what way this can
23
00:08:31,850 --> 00:08:42,490
be used for your sorting see what it gives
you that from this sequence A,
24
00:08:42,490 --> 00:08:51,610
You are making the tool sequence one is D
and another one is E right from this two sequence
25
00:08:51,610 --> 00:09:01,329
you make D and E now this recursively you
do the Patrick merge on that recursively ruther
26
00:09:01,329 --> 00:09:08,130
by drilling merge on this and you get another
subsequence like that and every time you are
27
00:09:08,130 --> 00:09:15,680
achieving one thing that these elements are
smaller than this elements these elements
28
00:09:15,680 --> 00:09:22,290
are smaller than this elements. So by some
recursive method if you can sort this one
29
00:09:22,290 --> 00:09:30,300
you can sort this one then the element becomes
the sorter.
30
00:09:30,300 --> 00:10:13,199
One now how to prove this theorem. You have
J = N J = N, J= N. So first thing is that
31
00:10:13,199 --> 00:10:26,569
the cyclic shifts of the sequence A will affect
both the D and E sequence similarly we do
32
00:10:26,569 --> 00:10:36,890
not affect being the property of these two
property if you do the cyclic shape it will
33
00:10:36,890 --> 00:10:47,769
affect both the sequence D and E right again
and but it will not it will not affect this
34
00:10:47,769 --> 00:10:50,050
properties right.
35
00:10:50,050 --> 00:11:07,619
So we issue that for simplicity we assume
the sequence is satisfying this type of actress
36
00:11:07,619 --> 00:11:26,279
first okay now second part is that the as
you mentioned the J can be = can be = N right
37
00:11:26,279 --> 00:11:38,610
now both the case if it is = N if it is = I
can see from this direction that this J becomes
38
00:11:38,610 --> 00:11:51,959
= N so if I look from this side agree understood
if J is = N if I see from that side Jake it
39
00:11:51,959 --> 00:11:59,389
becomes the = and that becomes also by tuning
sequel only = symbol it becomes the = to simple
40
00:11:59,389 --> 00:12:08,899
nothing else right so without any loss of
generality we assume the J is = we assume
41
00:12:08,899 --> 00:12:17,629
J is = and if I can show this one the other
one is also you can show. So for your show
42
00:12:17,629 --> 00:12:49,889
j is = N so you have A 1 = A 2 = to a n = to
A J, AJ + 1 A 2n.
43
00:12:49,889 --> 00:13:09,459
Now we have done it and this side
is = just such a = right no issue first cases
44
00:13:09,459 --> 00:13:20,240
there are two possible decay so is N = to
N and another case could be a = a 2 H these
45
00:13:20,240 --> 00:13:31,029
are the two possibilities you have this is
a n in = equals to a 2n or a n can be = n
46
00:13:31,029 --> 00:13:42,621
to n now let us assume that N equals 2 8 2
n first case in that case what is your di
47
00:13:42,621 --> 00:14:11,730
= VI is what minimum of A+I so what is the
DIA and who is the minimum yeah there is no
48
00:14:11,730 --> 00:14:30,480
ambiguity yes so I can write here and what
is he a N+ I agree basically this becomes
49
00:14:30,480 --> 00:14:43,370
in this becomes your D sequence this becomes
your new sequence yes.
50
00:14:43,370 --> 00:14:54,920
So this satisfies D 1 = to D 2 = equals to
= equal to DN and u 1 is = to e 2 = equals
51
00:14:54,920 --> 00:15:10,999
to
52
00:15:10,999 --> 00:15:25,080
yes because this side is you are = equal to
G minus n and then so this is a pirate sequence
53
00:15:25,080 --> 00:15:40,410
this is also a binary sequence for a part
of this case for this case here a 1 = equals
54
00:15:40,410 --> 00:15:49,220
2 a 2 = equals tool and get of any = equals
2 = equals to this get an N equals 2 and so
55
00:15:49,220 --> 00:16:02,339
on right on this element this is your AI and
corresponding element is maybe here suppose
56
00:16:02,339 --> 00:16:14,720
corresponding element is here A N + sign right
now if it is the case.
57
00:16:14,720 --> 00:16:21,639
So this is = so this is larger than this one
so minimum becomes di and maximum becomes
58
00:16:21,639 --> 00:16:33,459
here another possibility is that your CI is
here yeah is here yeah I + 1 e IE z KN + I
59
00:16:33,459 --> 00:16:46,289
is here this element is less than this n this
element is = this element this element is
60
00:16:46,289 --> 00:16:53,649
= this element so this element is less than
this element so this becomes di this becomes
61
00:16:53,649 --> 00:17:06,799
here so this becomes C D sequence this becomes
e sequence and both of them are by training
62
00:17:06,799 --> 00:17:20,170
sequences first part second part is the minimum
of maximum of the sequence is DN maximum of
63
00:17:20,170 --> 00:17:30,770
disciplines is the end minimum of each sequences.
What
64
00:17:30,770 --> 00:17:57,450
yes minimum of P 1 or here no a1 is either
be 1 u 1 is what u 1 is e 1 is your e n +
65
00:17:57,450 --> 00:18:13,100
1 and e n is your a 2 n agree now if it is
the case that and BN is your here you already
66
00:18:13,100 --> 00:18:20,820
have shown from the definition that n is = equal
to N + 1 from the definition itself because
67
00:18:20,820 --> 00:18:31,330
J is somewhere this is your end and this is
okay this element is always = this element
68
00:18:31,330 --> 00:18:46,160
and also by this case this element is = this
element agree so a so the end BN is always
69
00:18:46,160 --> 00:18:50,990
= equals to DM.
70
00:18:50,990 --> 00:19:18,350
In the next case is if I control for this
case also then you are probably. So this is
71
00:19:18,350 --> 00:20:29,280
given now I can always find out the keys in
such UK such that II I can always find out
72
00:20:29,280 --> 00:20:49,760
a K such that a K minus n = = K and a K - N
+ 1 k + 1 now how can you justify this what
73
00:20:49,760 --> 00:21:06,670
I have found that a G - N is = equal to a
G this is given to you agree a J minus 1 is
74
00:21:06,670 --> 00:21:15,190
= equal to AJ because from the definition
of your vital new sequence yes no you look
75
00:21:15,190 --> 00:21:28,860
for a J - n + 1 whether it is = a J +1 or
not suppose this is your J = M and this is
76
00:21:28,860 --> 00:21:35,770
your J so this satisfies the property this
is less the request of this know whether this
77
00:21:35,770 --> 00:21:44,870
element is larger than this element.
Suppose it is not that means this element
78
00:21:44,870 --> 00:21:51,900
is = equals to this element. You look for
the next one whether this element is larger
79
00:21:51,900 --> 00:22:01,870
than this element or not no suppose no but
in that case think about this one n - 1 and
80
00:22:01,870 --> 00:22:13,320
2 n - 1 so this element is = equal to this
element right because you are going one by
81
00:22:13,320 --> 00:22:25,540
one so you got the last case a n - 1 is = = 8
2 n - 1 but from the Assumption a n is = a
82
00:22:25,540 --> 00:22:35,890
2 well so you will get 1 K satisfying this
criteria I am looking for the first I am looking
83
00:22:35,890 --> 00:22:49,530
for the fastest K that. We are looking for
the smallest K satisfying this criteria right
84
00:22:49,530 --> 00:22:54,410
yes no yeah if it is cleared.
85
00:22:54,410 --> 00:23:14,830
Then you got this is then this is J this is
K this is K - n this is too much now here
86
00:23:14,830 --> 00:23:30,210
you have the three cases about your EIN E
and + I can be n + I can be here can be here
87
00:23:30,210 --> 00:23:46,490
can be here okay I can be here I can be here
so I can be here or here agreed. Now suppose
88
00:23:46,490 --> 00:24:02,010
I easier first case is I is here so what for
89
00:24:02,010 --> 00:24:17,570
and ice this is the first case if now you
tell me what should be your di and what should
90
00:24:17,570 --> 00:24:44,360
be your when I is n + I easier yeah easier
and also in this Joel while I mean I n + I
91
00:24:44,360 --> 00:25:02,520
in this.
Join can I write bi is = equal to d
92
00:25:02,520 --> 00:25:28,830
i +1 is = equals = this number not crossing
that from watching I can write here. So that
93
00:25:28,830 --> 00:25:37,720
up to this point up to this point and problem
is it okay yeah no let us take the second
94
00:25:37,720 --> 00:25:59,960
case
95
00:25:59,960 --> 00:27:15,840
I like and my N + I is can be here. So basically
I am going from this direction to this than
96
00:27:15,840 --> 00:27:30,300
from this to this I have used this properly
I have used this property right so you are
97
00:27:30,300 --> 00:27:49,260
writing VI is your AI right and what is the
relationship between VI l bi + di is and what
98
00:27:49,260 --> 00:28:25,710
is right. So you got the second chase now
I need the third case for cases okay J - and
99
00:28:25,710 --> 00:28:41,950
your I line here is here no you.
See here I can write AI + n is = to TI + n
100
00:28:41,950 --> 00:28:58,190
- 1 k + 1 Lisbon e k -
101
00:28:58,190 --> 00:29:20,880
n + 1 so this is here = equals to a K minus
n + 2 yeah I agree basically what I am doing
102
00:29:20,880 --> 00:29:32,070
I am moving from this side to this side here
it is K + 1 and then moving from this to this
103
00:29:32,070 --> 00:29:40,510
from this side to this K + 1 and I know the
relationship from k + putout k + 1 and k - n
104
00:29:40,510 --> 00:29:49,010
+ 1 I am moving from this to this okay if
it is ok then here I get this relation from
105
00:29:49,010 --> 00:30:11,210
here I can get d i and d i. what is the a
n + I and here he I and what is the relationship
106
00:30:11,210 --> 00:30:40,930
between di and di + 1 e in I + 1 bi e di is
= equals 2 because
107
00:30:40,930 --> 00:30:56,850
yes the I + 1 will be here. So this is bigger
than this and
108
00:30:56,850 --> 00:31:40,580
yet wait see here is coming this side right
a i this is a i+1 so if I
109
00:31:40,580 --> 00:31:43,040
combine all this plus one what I get first
.
110
00:31:43,040 --> 00:32:49,200
Let us consider d 1 case you get d1 = d 2
= d j-n = d j-n+1= d k-n then I do not know
111
00:32:49,200 --> 00:33:03,400
the relationship here d k-n+1 right here
112
00:33:03,400 --> 00:33:14,450
because here it ends up to d k and this side
I am starting from dk+n-1 I do not know what
113
00:33:14,450 --> 00:33:20,860
will be the relation so the relation we will
find out what is that relation up to this
114
00:33:20,860 --> 00:33:52,571
is known to you so what about e1 = e2 = e
j-n then you have = ej-n+1 = e k -n and I
115
00:33:52,571 --> 00:34:01,700
do not know the relationship between e k - n
and e k -n+1 and then I know this relation.
116
00:34:01,700 --> 00:34:15,659
Do you know any relationship between e1 and
en and what is the relationship between e
117
00:34:15,659 --> 00:34:56,089
1 and en here what is e1 it is a n+1 what
is your e n it is a n and do you know any
118
00:34:56,089 --> 00:35:38,230
relationship with e n
so I can write e n = e 1 agreed yes no in
119
00:35:38,230 --> 00:35:47,259
that case first you tell me if I know all
this so I know the relation here e n = e 1
120
00:35:47,259 --> 00:35:55,080
so think about this one can I tell that this
is a binary sequence irrespective of what
121
00:35:55,080 --> 00:36:05,049
about the relationship between these two .
Suppose it is = then it is a your binary sequences
122
00:36:05,049 --> 00:36:10,720
if it is = then also it is binary sequences
so this is a binary sequence what about this
123
00:36:10,720 --> 00:36:22,119
one this is also binary sequence because by
cyclic shift I can find out this is = e 1
124
00:36:22,119 --> 00:36:34,619
= up to e j- n right then I can get e j- n
+ 1 = e k - n whatever the relationship between
125
00:36:34,619 --> 00:36:39,299
this again less than equals to this so it
becomes the binary sequence.
126
00:36:39,299 --> 00:36:47,420
So the first part is that d and e are binary
sequence now what you have to show that maximum
127
00:36:47,420 --> 00:36:54,609
of d < minimum of d now suppose you have a
binary sequence.
128
00:36:54,609 --> 00:37:06,200
Now suppose you have a binary sequence now
a 1 ,a2, a 3 up to a n like what should be
129
00:37:06,200 --> 00:37:20,320
your network this always looks like that you
have comparators n/2 comparators and you have
130
00:37:20,320 --> 00:37:49,329
a n / 2 + 1 n / 2 + 2 and so on so it goes
like this okay so this is a binary sequence
131
00:37:49,329 --> 00:38:11,980
so a i has to be compared with a n +i so same
thing we did and then you get n /2 by two
132
00:38:11,980 --> 00:38:40,380
merging networks and you have n /2 binary
merging networks right so you get here basically
133
00:38:40,380 --> 00:38:54,890
d 1 d 2 up to d n/2 you get e 1 e 2 e n by
then recursively.
134
00:38:54,890 --> 00:39:11,319
If you call you get C 1 C 2 C 3 C n/ 2 you
get C n / 2 + 1 C n right so you have applied
135
00:39:11,319 --> 00:39:18,380
one comparator a i is compared with a n / 2
+ I smaller elements you keep it in this discipline
136
00:39:18,380 --> 00:39:24,131
larger you will bring it to a sequence then
recursive this becomes a bi tonic sequence
137
00:39:24,131 --> 00:39:34,140
and recursively you do it and then finally
you get the sorted sequence this side right.
138
00:39:34,140 --> 00:39:47,420
Now if it is the case then how many comparators
you need
139
00:39:47,420 --> 00:40:10,220
number of comparators is n / 2 + T n / 2 =2
times if n = 2 and 1 if n= 2 and if n is = 2
140
00:40:10,220 --> 00:40:30,979
1 if n is mystical .Because you have 2 elements
and one comparator and the number of steps
141
00:40:30,979 --> 00:40:55,549
parallel steps you need T n = 1 + T n/ 2 if
n > 2 1 if n=2 right because 1 and then what
142
00:40:55,549 --> 00:41:09,289
about time you need now issue n = 2 k .
143
00:41:09,289 --> 00:41:44,800
So you can easily solve T n right because
this becomes T 2 also becomes 1 so I display
144
00:41:44,800 --> 00:41:47,420
k which is your log n .
145
00:41:47,420 --> 00:42:22,599
Now if I have to compute C n = 2 (2 C n/22+
n/22 ) 22 C n/22 +n / 2 +n/2 then 2 k- 1 C
146
00:42:22,599 --> 00:43:03,970
n / 2 k- 1 so 2 k- 1 because C 2 is 1 so you
get (k-1) n/2 and this is also 1 n /2 right
147
00:43:03,970 --> 00:43:41,359
so you get k n/ 2 that is n /2 log n. So you
got C n =n/2 log n is to merge a
148
00:43:41,359 --> 00:43:52,349
bi tonic sequence and once do you observe
that you must have a bi tonic sequence to
149
00:43:52,349 --> 00:43:58,920
merge this one so the sequence must be vital
in sequence if I have to think that how can
150
00:43:58,920 --> 00:44:04,309
I use this idea to sort an arbitrary element
.
151
00:44:04,309 --> 00:44:28,080
So let us go to the eight elements 71 2 4
3 6 5 8 that the idea is you use the elements
152
00:44:28,080 --> 00:44:33,819
are always bi tonic and then you merge it
and you must get it and after merging you
153
00:44:33,819 --> 00:44:48,789
must get the larger bi tonic sequence so basically
it is nothing but the idea is that you
154
00:44:48,789 --> 00:44:53,559
this one you make it increasing sequence this
one you make it decreasing sequence so that
155
00:44:53,559 --> 00:44:58,579
you get at the end of this you get a bi tonic
sequence of larger size.
156
00:44:58,579 --> 00:45:12,970
So here you are beginning 17423685 see you
observe now this is a binary sequence this
157
00:45:12,970 --> 00:45:20,539
is another bi tonic sequence you convert this
into a sorted sequence in increasing order
158
00:45:20,539 --> 00:45:26,499
this should be in increasing order and this
should be decreasing order so that this becomes
159
00:45:26,499 --> 00:45:32,999
another bi tonic sequence so in order to do
that this would be an increasing order you
160
00:45:32,999 --> 00:45:45,829
first compare a i has to be compared with
the n +i .
161
00:45:45,829 --> 00:45:55,390
So you get here 1247 now this becomes a bi
tonic sequence and this becomes a bi tonic
162
00:45:55,390 --> 00:46:10,220
sequence so you get a sorted sequence here
similarly is the case here
163
00:46:10,220 --> 00:46:22,400
so you compare these two you get 8 3 6 5 and
then you compare this 2 you get 8653 so this
164
00:46:22,400 --> 00:46:35,539
is becoming another bi tonic sequence now
you observe at the
165
00:46:35,539 --> 00:46:43,660
end of this case you get a bi tonic sequence
of side A now you have to make it a sorted
166
00:46:43,660 --> 00:46:47,849
sequence .
So a i has to be compared that means this
167
00:46:47,849 --> 00:46:57,210
has to be compared this has to compare with
this and this has to be compared with this
168
00:46:57,210 --> 00:47:09,759
right after doing that so if I compare 1 with
8 you will get 1 2 with 6 you will get 6 here
169
00:47:09,759 --> 00:47:19,660
4 with 5 and you will get 4 here and 5 here
and 3 with 7 here 7 here now the problem is
170
00:47:19,660 --> 00:47:25,540
that this is a bi tonic sequence and this
is another bi tonic sequence and all these
171
00:47:25,540 --> 00:47:28,430
elements is larger than these elements right
.
172
00:47:28,430 --> 00:47:41,690
Because d i is smaller than e i so you now
compare this with this with this you get here
173
00:47:41,690 --> 00:48:10,660
1 4 2 3 5867 then you compare with this 12345678
now how many parallel steps you need parallel
174
00:48:10,660 --> 00:48:24,489
phrases you need this is phase 1 phase 2 phase
3 so if you have a bi tonic sequence if you
175
00:48:24,489 --> 00:48:29,589
have the sequence of 8 elements there were
three phases that means you have the login
176
00:48:29,589 --> 00:48:40,599
phases anyway and the i th phase you have
at the ith phase.
177
00:48:40,599 --> 00:48:53,729
You have several parts each of size 2 i bi
tonic sequence at the ith phase there are
178
00:48:53,729 --> 00:48:57,969
log n phases.
179
00:48:57,969 --> 00:49:16,289
A the ith phase
there are several bi tonic sequences each
180
00:49:16,289 --> 00:49:46,239
of size 2 i now can you tell me what is this
value of several then
181
00:49:46,239 --> 00:50:01,880
and n / 2 i yes that is 2 k-i n =2k right
so that many parts are there in this case
182
00:50:01,880 --> 00:50:17,229
second phase you have 2 i 2 4 and there are
two such cases so it is 2 k-i actually subsequences
183
00:50:17,229 --> 00:50:38,369
each of size 2i agreed now if it is the case
so can we find out total number of parallel
184
00:50:38,369 --> 00:50:54,599
steps
and number of comparators
185
00:50:54,599 --> 00:51:08,020
and then type of comparators.
So we need to know these three things you
186
00:51:08,020 --> 00:51:15,500
observed that here it is not like odd even
merging that comparator has two inputs and
187
00:51:15,500 --> 00:51:22,050
the output is the first output is the minimum
and second output is maximum here it is depending
188
00:51:22,050 --> 00:51:30,529
upon the phase whether it is an increasing
order or decreasing order right so there are
189
00:51:30,529 --> 00:52:02,559
two types of comparators you will be using
a and b min (a ,b) and max(a, b) right actually
190
00:52:02,559 --> 00:52:11,589
it is not very difficult to implement .
So the first one if you can implement only
191
00:52:11,589 --> 00:52:24,469
the word you have to change and to give you
maximum output in the top only thing is that
192
00:52:24,469 --> 00:52:32,259
you have phase wise you have to keep it in
mind which comparators you would be going
193
00:52:32,259 --> 00:52:39,210
to use right the first phase alternatively
high low high low high low here is second
194
00:52:39,210 --> 00:52:49,910
phase it is low low high high then it is low
that is the only thing right .
195
00:52:49,910 --> 00:52:55,559
So these are some easily you can there is
this so the type of comparators you will be
196
00:52:55,559 --> 00:53:03,079
using that is known to you now what about
these two
197
00:53:03,079 --> 00:53:12,560
well number of parallel steps first phase
one parallel steps second phase how many parallel
198
00:53:12,560 --> 00:53:26,760
steps right how many parallel steps this is
one and this is another one agree third one
199
00:53:26,760 --> 00:53:35,579
is what how many parallel steps this is one
this is number of parallel steps you have
200
00:53:35,579 --> 00:53:44,319
already obtained and the start steps you have
2 3 elements.
201
00:53:44,319 --> 00:53:52,469
They are binary sequence and you are making
3 parallel steps and at the ith phase you
202
00:53:52,469 --> 00:54:03,609
are making i parallel steps so I parallel
steps at the ith stage how many I and i is
203
00:54:03,609 --> 00:54:21,549
1 to log n so it is log n log n + 1 which
is order log square n so number of parallel
204
00:54:21,549 --> 00:54:35,069
step is order (log 2 n)now can you tell me
the how to find out the number of comparators
205
00:54:35,069 --> 00:54:47,559
at the ith stage
how many parts are there 2i 2 n-i that many
206
00:54:47,559 --> 00:54:57,709
sub parts are there in the ith stage 2 n-i
sub parts are there this is the bi tonic sequence
207
00:54:57,709 --> 00:55:22,979
size 2i agreed.
So this is 2 i-1 i ? over i=1 to log n
208
00:55:22,979 --> 00:55:31,479
there are n - 2 k-i sub parts are there each
part is a size of 2i which is the bi tonic
209
00:55:31,479 --> 00:55:41,470
sequence to do that you need the number of
comparators i(2 i-1 ) which has come from
210
00:55:41,470 --> 00:56:11,289
here agreed if it is
that this becomes ? over 1 to log n over 2
211
00:56:11,289 --> 00:56:35,549
k-1 I and 2 k-1 goes out and which is again
log n (log n+1)/2 and which is O(n log2 n)
212
00:56:35,549 --> 00:56:55,500
so you can write the number of comparators
you will get and number of parallel steps
213
00:56:55,500 --> 00:57:13,329
is O( log2 n)and the cost is O(n log4n) it
is also far away from the point.
214
00:57:13,329 --> 00:57:18,859
Now so what should be the basic units of bi
tonic sequence specifically suppose you have
215
00:57:18,859 --> 00:57:58,489
the four elements or elements and which form
a bi tonic sequence right that is the two
216
00:57:58,489 --> 00:58:09,829
elements two elements who needs to give you
th sorted sequence four elements if you have
217
00:58:09,829 --> 00:58:14,610
four elements which forms a bi tonic sequence
and the structure is like that now if you
218
00:58:14,610 --> 00:58:19,739
have to combine both the things for obtaining
a sorted sequence.
219
00:58:19,739 --> 00:58:24,321
Suppose it is an arbitrary elements and you
want to have the sorted sequence you can easily
220
00:58:24,321 --> 00:58:36,589
find out that this we suppose this is an arbitrary
one you want a 1 a2 a3 so first you make this
221
00:58:36,589 --> 00:58:45,651
is low and this is high and this is high this
is low now this becomes a bi tonic sequence
222
00:58:45,651 --> 00:59:21,049
now in the second phase second phase you get
low high so you will get the sorted sequence
223
00:59:21,049 --> 00:59:50,569
right and then if you observe if you compare
this with odd even merge techniques.
224
00:59:50,569 --> 01:00:00,299
You will find what that was if you have a
odd even merge you first do the odd even merge
225
01:00:00,299 --> 01:00:15,059
network + n-1 you do not need the comparators
here you need so number of comparators is
226
01:00:15,059 --> 01:00:21,999
increasing cost-wise is of the same order
there is no problem moreover in odd even merge
227
01:00:21,999 --> 01:00:28,619
you have to keep track what event are useful
to keep a low high I know all those information
228
01:00:28,619 --> 01:00:41,969
which you do not have to keep for odd even.
So this is all about your bi tonic sequence
229
01:00:41,969 --> 01:01:18,309
any questions on this I do not want to start
the sorting algorithm suppose you will realize
230
01:01:18,309 --> 01:01:32,800
for network model which may not be possible
for odd even merge not comfortable compared
231
01:01:32,800 --> 01:01:45,549
to the latest it is also you have to keep
track with how many how many high-low comparators
232
01:01:45,549 --> 01:02:09,779
you mean right and did you go through the
minimum sorting network minimum number of
233
01:02:09,779 --> 01:02:16,480
comparators that.
We have a chapter is in volume 3 so please
234
01:02:16,480 --> 01:02:28,191
go through that the sorting network is happening
there can you use any one of them see you
235
01:02:28,191 --> 01:02:38,140
here you observe what do we do we started
with two elements two elements instead of
236
01:02:38,140 --> 01:02:51,450
that if I use five elements but they can achieve
the goal of sorting how much that type of
237
01:02:51,450 --> 01:02:58,469
things you can take because what we observe
that if the number of elements is odd the
238
01:02:58,469 --> 01:03:08,829
number of comparators takes less place to
sort.