1
00:00:31,330 --> 00:00:38,330
So, today we will be discussing only odd or
even merge sorting network. So, and since
2
00:00:47,220 --> 00:00:54,220
I assume that you do not know anything about
odd even merging. So, first we will be discussing
3
00:01:05,350 --> 00:01:12,350
odd even merging technique, sequential algorithm.
Just then we will be discussing the odd even
4
00:01:17,610 --> 00:01:24,479
merging network and then finally, would be
discussing about odd even merging and sorting
5
00:01:24,479 --> 00:01:30,180
network. First we will discuss about sequential
odd even merge technique, second will be discussing
6
00:01:30,180 --> 00:01:37,060
odd even merge network and then finally, sorting
network.
7
00:01:37,060 --> 00:01:44,060
So, this is special purpose sorting network.
Let us assume that
a and b are the 2 sorting sequence and the
8
00:01:58,810 --> 00:02:05,810
problem is to merge this 2 sorted sequence
by odd even merging technique. What it does
9
00:02:29,269 --> 00:02:36,269
that it forms a1 a2 are the 2 different sets.
a1 contains the elements which are added next
10
00:03:17,180 --> 00:03:24,180
and a2 contains the elements which are given
index. Similarly, is the case of b1 and b2.
11
00:03:38,900 --> 00:03:45,900
Now by odd even merging technique recursively
merge a1 b1 and similarly, a2 b2, right.
12
00:04:12,500 --> 00:04:19,500
Say we have sequence a sequence b. Now you
get a1 b1 a2 b2, right, you have the odd even
13
00:04:35,990 --> 00:04:42,990
merging technique. You are defining same thing
you are defining here odd even merging technique
14
00:04:45,009 --> 00:04:52,009
recursively, you get d sequence you get e
sequence recursively. You have d1 the odd
15
00:04:57,020 --> 00:05:00,009
even merge of this you get d sequence you
get e sequence again. So, it’s d now, if
16
00:05:00,009 --> 00:05:07,009
it is a case then can I draw the conclusion
b1 is the minimum? Sure, can I draw the conclusion
17
00:05:45,409 --> 00:05:47,779
because minimum is either a1 or b1 right.
18
00:05:47,779 --> 00:05:54,779
So, d1 is the minimum that conclusion I can
draw. Similarly, can I do the conclusion that
19
00:05:57,080 --> 00:06:04,080
en is the maximum? Right, this too is clear
to you. Now second thing is that which is
20
00:06:12,909 --> 00:06:19,909
the second element second small? Any idea?
d2 of u r right so this is the thing this
21
00:06:24,990 --> 00:06:31,990
idea has been taken so let us define c 1is
d 1c 2i is minimum of d i plus 1e i i is equal
22
00:06:46,659 --> 00:06:53,659
to 12on words and c 2n is your here c 2i plus
1actually i have to write somewhere zero so
23
00:07:11,669 --> 00:07:18,669
thus i am tell the who is the next form here
c 2i plus 1is maximum of d i plus 1e i i is
24
00:07:21,379 --> 00:07:28,379
12x
So that is the things say what is the stating
25
00:07:33,099 --> 00:07:39,139
what is the common problem is that given a
and given b 2sorted sequences i pick up the
26
00:07:39,139 --> 00:07:46,139
odd sequences which form a 1odd sequence of
b gives you b 1even that index elements form
27
00:07:50,210 --> 00:07:55,740
a 2and b 2recursively you are merging a 1b
1you get the sequence b 1to d n similarly,
28
00:07:55,740 --> 00:08:02,740
you get the sequence e e 1to e n now s 1is
given c 2n is e n and c 2i is define by the
29
00:08:05,819 --> 00:08:09,939
minimum of d i plus 1e n e i and c 2i plus
1is maximum of e i plus 1here
30
00:08:09,939 --> 00:08:16,939
Right now we have to prove that this give
the sorted sequence that is the only thing.
31
00:08:23,409 --> 00:08:30,409
If we can prove this you are happy. So, this
obviously we go up to prove it, this is obvious
32
00:08:35,169 --> 00:08:42,169
you do not prove this part, only thing is
that you have to prove this part. Now, let
33
00:08:43,610 --> 00:08:50,610
us consider the subsequence of D that is d1
d2 d i plus 1. Let us consider this subsequence
34
00:09:05,300 --> 00:09:12,300
and you will find it said this twice the criteria
because, this is recursively sorted is satisfy
35
00:09:19,800 --> 00:09:22,650
this criteria.
36
00:09:22,650 --> 00:09:29,650
Now, let us assume k of them belong to A sequence,
because d1 d2 …di plus 1. This D sequences
37
00:09:42,030 --> 00:09:49,030
obtained from odd the index subsequence of
a and odd the index subsequence of b. So,
38
00:09:53,110 --> 00:10:00,110
either we can assume the k of them belong
to s a sequence. What is a, a means a 1sequence
39
00:10:06,600 --> 00:10:13,600
k 1after belonging to a 1sequence then, does
it imply that i plus 1minus k of them belongs
40
00:10:18,510 --> 00:10:25,510
to b ones of b 1sequence to this total number
elements? Take it better listed please tell
41
00:10:34,290 --> 00:10:41,290
me. k of this is are option k of them belong
to this it indicates. Then i plus 1minus k
42
00:10:46,180 --> 00:10:53,180
of them belong to b sequence now, what does
it mean that k of them belong to s a 1sequence
43
00:10:53,580 --> 00:11:00,580
means that a 1 a 3 a 5 and so on. And you
got what is the index of this 2k plus 1is
44
00:11:10,080 --> 00:11:17,080
it, if it is the case then can i write how
many of them what would be the highlight belong
45
00:11:24,030 --> 00:11:31,030
to original a sequence original, what should
be the number here 2, see how many elements
46
00:11:43,650 --> 00:11:50,650
are here k elements.
47
00:11:52,350 --> 00:11:59,350
So, k elements are you sure hundred percent,
i have 3 elements here. How many elements
48
00:12:04,520 --> 00:12:11,520
are here a 1a 3 and a 5. No this index may
be wrong I do not know, sure hundred percent.
49
00:12:19,290 --> 00:12:26,290
You have 3 elements in between how many elements
are there, how you are telling k if this 1may
50
00:12:46,570 --> 00:12:53,570
be 2k minus 1may be 2k minus i. I am not talking
about this part I am taking that I have odd
51
00:13:05,630 --> 00:13:12,630
index elements and between the odd index how
many even index elements are there. That is
52
00:13:26,820 --> 00:13:28,080
k minus one
53
00:13:28,080 --> 00:13:35,080
So, I can write it is k minus 1agree. So,
what is that 2k minus 1because, k minus 1even
54
00:13:35,820 --> 00:13:42,820
index elements k elements are odd index elements.
So, total 2k minus 1elements were belonging
55
00:13:44,640 --> 00:13:51,640
to a sequence and they are because this is
sorted degrade. Now, if it is a case so, can
56
00:14:07,890 --> 00:14:14,890
you tell me from here how many elements of
that belonging to b sequence? How many odd
57
00:14:16,490 --> 00:14:23,490
index elements i plus 1minus k and how many
even index elements i, i minus k then, what
58
00:14:28,460 --> 00:14:35,460
is the total number of elements why 2i plus
1minus 2k that may elements belonging to b
59
00:14:44,060 --> 00:14:51,060
sequence. What does it mean 2k belonging to
a sequence which is less than and equals to
60
00:14:52,070 --> 00:14:59,070
d i plus 1that many elements. Which is less
than equals to d i plus one?
61
00:15:00,920 --> 00:15:07,920
Is it what we did first, we do not that a
element of b subsequence belonging to a 1sequence
62
00:15:12,350 --> 00:15:18,350
it indicate that i plus 1minus 1elements belonging
to b 1sequence it indicates that 2k mi it
63
00:15:18,350 --> 00:15:23,790
indicates the 2k minus 1elements belonging
to a sequence less than equals to b i plus
64
00:15:23,790 --> 00:15:30,790
1. and similarly, 2i plus 1minus 2k elements
belonging to b sequences less than b i plus
65
00:15:41,529 --> 00:15:48,529
1 and if I add this 2 what i get 2i elements
belonging to a and b less than equals to b
66
00:15:53,910 --> 00:15:57,400
i plus 1.
67
00:15:57,400 --> 00:16:04,400
Now, if see the sorted sequence so, can i
write c 2i is less that equals to d i plus
68
00:16:12,589 --> 00:16:19,589
1 because by combining this 2 either 2i elements
belonging to the combined a and b is less
69
00:16:21,650 --> 00:16:28,650
than equals to d i plus 1. And since c is
the sorted sequence that is the assumption
70
00:16:31,970 --> 00:16:38,970
so, c 2i is less than equals to di plus 1similarly,
you can show c 2i is less than equal to e
71
00:16:40,760 --> 00:16:47,760
i just start with d i 1and you get. So, let
us considers the subsequence c 1c 2c 3 c 2i
72
00:17:01,410 --> 00:17:08,410
plus 1now, this is sorted sequence. So, i
can write this is equals to this.
73
00:17:15,480 --> 00:17:22,480
Now, let us assume that k of them belonging
to a sequence so, i can write this is assumption
74
00:17:40,860 --> 00:17:47,860
i can write 2i plus 1minus k of them belonging
to b sequence because obviously, that can
75
00:17:52,139 --> 00:17:59,139
c has been obtain from a and b only. Now can
you tell me how many of them in that case
76
00:18:03,470 --> 00:18:10,470
from here of them belonging to a 1 sequence
say this is a subsequence belonging to c?
77
00:18:14,009 --> 00:18:21,009
How many of them belonging to a 1 sequence.
Now, the k should either given order if it
78
00:18:24,619 --> 00:18:31,619
is odd, what is the value and you can remain?
So you would be writing k of i 2 of them belonging
79
00:18:49,490 --> 00:18:56,490
to a 1if k is even else k plus 1by 2of them
belonging to you.
80
00:19:03,210 --> 00:19:10,210
Read it now if it is a case from here, can
i write something how many of them belonging
81
00:19:21,389 --> 00:19:28,389
to b 1 sequence. Now, assume that k is even
assume first k is even otherwise if k is odd
82
00:19:38,460 --> 00:19:45,460
you have to 2 little manipulation that i 2i
plus 1minus k divided by 2. Some manipulation
83
00:19:48,619 --> 00:19:55,619
apart k, k equals to k s or what should be
the changing design of in both the case if
84
00:20:00,399 --> 00:20:07,399
i get it. Tell me if add this 2i get i plus
1of them so, belonging to k by 2of them belonging
85
00:20:19,169 --> 00:20:26,169
to a 1subsequence which is less than equals
to c 2i plus 1 k by 2of them belonging to
86
00:20:46,970 --> 00:20:53,509
a 1subsequence to be less than that is the
thing i consider up to this. So, I can write
87
00:20:53,509 --> 00:20:54,139
this is less than to c 2i plus 1.
88
00:20:54,139 --> 00:21:01,139
Similarly, I can write this is less than equals
to c 2 i plus 1that means i plus 1of them
89
00:21:05,159 --> 00:21:12,159
belonging to a 1union b 1or the merge of a
1a 2a 1b 1is less than equals to c 2i plus
90
00:21:18,499 --> 00:21:25,499
1 and, this gives you the condition that d
i plus 1is less than equals to c 2i plus 1because,
91
00:21:26,249 --> 00:21:33,249
i plus 1of them d i plus 1is 1 d is the sequence
of a 1union b 1. So, b i plus 1is the first
92
00:21:45,239 --> 00:21:52,239
i plus 1elements of this 1so, i can write
d i plus 1is less than equals to c 2i plus
93
00:21:55,559 --> 00:21:55,989
one.
94
00:21:55,989 --> 00:22:02,989
Similarly, you can write e i is less than
equals to c 2 i plus 1 so, combining this
95
00:22:07,789 --> 00:22:14,789
four equations you can write that d i plus
1is minimum of not d i c i is c 2 i because
96
00:22:24,389 --> 00:22:31,389
you knows that c 2 i is less than equals to
c 2i plus 1.So, from here you can write d
97
00:22:42,110 --> 00:22:49,110
i plus 1e i and c 2 i plus 1is maximum of
d i plus 1, combining this four equations
98
00:23:10,279 --> 00:23:17,279
along with this you can easily prove this
so, the odd even merge technique correctly
99
00:23:18,730 --> 00:23:25,730
merges 2 sequence a and b as stores at a sequence
c this idea can be use to define the merging
100
00:23:27,679 --> 00:23:34,679
network, you have suppose n elements these
are a 1a 2 a 3 a 4 b 1b 2b 3 b 4 and you have
101
00:23:54,049 --> 00:23:57,070
a record name is n by 2cross n by 2network
odd even.
102
00:23:57,070 --> 00:24:04,070
Here input is odd indexed and here input is
all even in that limit. So, some recursive
103
00:24:45,419 --> 00:24:52,419
technique you get the sequence d 1d 2 d 3
d 4 d n you get e 1 e 2 e n so, d 1is your
104
00:24:59,450 --> 00:25:06,450
c 1 e c 2 f and then d 2 is compared with
d 1to get c 2 c 3 d 3 is compared with e 2
105
00:25:13,840 --> 00:25:20,840
to get c 4 c 5 you get d 4 is compared with
c 6 c 7 and so on this is the simple network
106
00:25:40,690 --> 00:25:47,690
in that case if it is the thing so, what I
need in this simple comparator I need a cross
107
00:26:21,799 --> 00:26:28,799
which is nothing but, a comparator now, the
comparator is define like this you have a
108
00:26:34,019 --> 00:26:41,019
input a, u have a b and output is minimum
of a comma b maximum of a comma b.
109
00:26:46,429 --> 00:26:53,429
So, you need a comparator here which take
the input and give to the output like this.
110
00:26:57,869 --> 00:27:04,869
Now, if I have the 2 elements a and b how
many comparator unit to ((slov)) mark this
111
00:27:10,499 --> 00:27:17,499
2 sequence 1comparator and the structure is
very simple. Now, if I have I need this later
112
00:27:22,210 --> 00:27:29,210
on, now we have a 1 a 2 b 1 b to these are
the 2 sequences each of size to your need.
113
00:27:30,609 --> 00:27:37,609
What should be the now, first problem is then
I want to find out the number of comparators,
114
00:27:51,629 --> 00:27:58,629
you need to merge the 2 sorted sequence each
of size n the number of comparators you need
115
00:28:21,929 --> 00:28:28,929
to merge 2 sequences each of size n.
Tell me n minus 1 are you sure? Tell me what
116
00:29:51,309 --> 00:29:58,309
is the number first, how do you do that you
obtain a recurrence relation what is the recurrence
117
00:31:00,950 --> 00:31:07,950
relation. So, tell me the recurrence relation.
Tell me what is the recurrence relation 2
118
00:31:17,039 --> 00:31:24,039
n minus 1this is the number of process you
need, how did you get that now how did you
119
00:31:44,289 --> 00:31:51,289
get it is 2n minus 1something has computer
mind based on some base. Basis what is that
120
00:32:13,289 --> 00:32:20,289
basis 2 n prepare how to how do you because
my feeling is that this type of problems,
121
00:32:28,159 --> 00:32:35,159
you can easily solve through recurrence relation
I do not know other way how you can do it.
122
00:32:38,629 --> 00:32:45,629
If you have any new idea tell me that would
it be use full for me. So, if I consider c
123
00:32:52,779 --> 00:32:59,779
2 n because, do not 2n in c 2 n is my comparator
is the number of comparators you need then
124
00:33:38,109 --> 00:33:45,109
c 2 n can be written as c n for this block
and for this block also unit again see there.
125
00:34:24,490 --> 00:34:31,490
So, 2 c n plus how many comparators unit then
minus 1plus n minus 1 and you know a recourse
126
00:35:16,470 --> 00:35:23,470
relation is vary if you put boundary quotation
also. So, 1way is in that case 1if n equals
127
00:35:41,860 --> 00:35:48,860
to 1if n is greater than one.
128
00:35:51,830 --> 00:35:58,830
Now, if it is a case you check whether you
recirculation varying for this or not that
129
00:36:00,760 --> 00:36:07,080
is n equals to 22 into c 1c 1is 12 into 1is
2plus, 1see unit the c comparator agree so,
130
00:36:07,080 --> 00:36:14,080
this is the number of comparators you need
will solve it later on now next 1is the number
131
00:36:31,580 --> 00:36:38,580
of parallel steps you need how many steps
you need or what is the time of to merge 2
132
00:36:56,890 --> 00:37:03,890
sorted sequences can you tell me. Now, t 2n
is equals to what tell me the recurrence function
133
00:37:32,890 --> 00:37:39,890
why to create this 2hubs but, they can do
it parallel analysis so, I can write t n plus
134
00:37:41,660 --> 00:37:48,660
1if n is greater than 11 if n equals to 1
anything else, I have to find out 1is number
135
00:38:02,430 --> 00:38:09,430
of comparators another 1is number of now I
need to know the solution of this 2 so, I
136
00:38:38,490 --> 00:38:45,490
can write this 1as t n by 2to the power of
k plus 11, 11 how many 1k minus 1next time
137
00:38:51,410 --> 00:38:58,410
I will write t n by 2 to the power 2 is equals
to 1 plus, 1 plus 1sure k plus 1k minus 1is
138
00:39:52,040 --> 00:39:59,040
not there now, k is them still or not sure
so if it is k plus 1then it is k plus 2 because
139
00:41:17,810 --> 00:41:24,810
this is t 1t 1is 1so, k plus one.
140
00:41:53,620 --> 00:42:00,620
So, t 2n t 2n is your k plus 2 so, basically
if I have to write t times of n it is k plus
141
00:42:55,410 --> 00:43:02,410
1, if I have to write in terms of n then it
is t n is equal to k plus 1, while writing
142
00:43:28,550 --> 00:43:35,550
the time which and not can 2n now, if it is
n this k plus 1now what about this solution
143
00:43:40,650 --> 00:43:47,650
2 times c n plus n minus 1now, tell me what
I write is it can, I write this can I get
144
00:44:13,500 --> 00:44:20,500
this yes or no if it is that then I can write
2 square c n by 2 plus n minus 2 plus n minus
145
00:44:33,600 --> 00:44:34,060
one.
146
00:44:34,060 --> 00:44:41,060
So, next time what I will write tell me, what
I will write here 22cube here c n by c n by
147
00:44:44,360 --> 00:44:51,360
4 here n minus is it so, what happens to k
time 2 to the power k plus 1c n by 2 to the
148
00:44:53,670 --> 00:45:00,670
power k n minus 2 to the power k. So, how
many ns k ns tell me k plus 1where this 1k
149
00:45:06,760 --> 00:45:13,760
plus 12 to the power zero 2 to the power 1
and so, it is gives you k plus 1n plus 1 so,
150
00:45:23,210 --> 00:45:30,210
you get c 2n k plus 1n plus 1so, you can what
is the value of c n k n plus 1k is log n k
151
00:45:31,740 --> 00:45:38,740
is long n. So, n log n plus 1 now, first is
c n into t n c as in n log n plus 1and t n
152
00:46:11,880 --> 00:46:18,880
is log n plus 1which is ordered then you got
it and belongs specification. Now, what is
153
00:46:30,790 --> 00:46:37,790
the sequential lower bound to mark the 2 sorted
sequence of each of size n. What is the lower
154
00:46:59,320 --> 00:47:06,320
bound 2n are you sure to merge the 2 sorted
sequence each of size n, what is the lower
155
00:47:18,600 --> 00:47:25,600
bound 2n minus 1it is n plus n minus 1. So,
it is 2n minus 1 so, it is order n and it
156
00:48:05,440 --> 00:48:12,440
is not this is logs square factor in a way
from the lower bound.
157
00:48:38,650 --> 00:48:45,650
So, the this is your parallel odd even merging
network. Now, can I use this merging network
158
00:49:08,810 --> 00:49:15,810
to sort the energumens? let us assume that
a1 a2 a3 a4 a5 a6 a7 and so on this other
159
00:50:51,200 --> 00:50:58,200
an elements there admit really recruited and
you want to sorted using odd even merging
160
00:51:48,720 --> 00:51:55,720
technique the strategy is very simple. You
assume that there are n by 2 groups each of
161
00:52:20,800 --> 00:52:27,800
size and these 2 side group is a 2 subsequences.
Each of them sorted that is that I have defined
162
00:52:50,770 --> 00:52:57,770
that this is a group, this is another group,
this is another group and this is another
163
00:53:02,780 --> 00:53:09,780
group and so on. And we assume that the 2
sequences each of size 1.
164
00:53:23,710 --> 00:53:30,710
Now, this is sorted this sequence is sorted,
this sequence is sorted, this sequence is
165
00:53:44,650 --> 00:53:51,650
sorted and this sequence is sorted if it is
the case I can have 1comparator to give me
166
00:54:15,700 --> 00:54:22,700
the sorted sequence. I can have another comparator
so, I get a 1 new a 1 new a 2 new a 3 new
167
00:54:28,530 --> 00:54:35,530
a 4 and so on. Now, you have n elements these
n elements property in that the other n by
168
00:54:35,590 --> 00:54:42,590
2 sequences n by 2 sequences is sequences
of size 2 and they are sorted.
169
00:54:45,310 --> 00:54:52,310
Now, you dividing in based on 4 elements,
4 elements, 4 elements these 2 elements sorted
170
00:54:57,670 --> 00:55:04,670
these 2 element sorted you can use odd even
merging of merging network to sort this you,
171
00:55:11,130 --> 00:55:18,130
can use the odd even merging network sort
this and so on agreed,. So, after some step
172
00:55:25,230 --> 00:55:32,230
you will find then you have n by 2 sorted
sequence n by 2 sorted sequence and you use
173
00:55:50,120 --> 00:55:57,120
a merging sorting network of size n by 2 plus
n by 2. So, give you a sorted sequence of
174
00:56:19,940 --> 00:56:26,940
size n so, if it is the case now you tell
me what is the number of steps you need and
175
00:56:51,670 --> 00:56:58,670
then number of comparator x unit.
176
00:57:10,330 --> 00:57:17,330
So, these are the two things you have to find
out that number of steps you need then number
177
00:58:27,670 --> 00:58:34,670
of comparators you need here. We obtain t
n c n t n is what t n is log n plus 1and this
178
00:59:49,680 --> 00:59:56,680
is n log n plus 1. Then we obtain already
now, this strategy let us first for simplicity.
179
00:59:59,210 --> 01:00:05,460
Let, us consider 1example then you realize
tell me 8 random numbers 1of them you can
180
01:00:05,460 --> 01:00:11,280
5 the next number 7 4 said 2 8 t this is the
8 numbers you have.
181
01:00:11,280 --> 01:00:17,540
So, use comparators here output is 5 7 24
13 6 8 now use 5 is come 2is come here 7 4
182
01:00:17,540 --> 01:00:24,540
16 3 8. So, 2and here 5 will come here 7 4
4 5 here 16 3 3 6 8 now, this 1 basically
183
01:00:24,970 --> 01:00:31,970
like all repair. What is this same 2 has come
this is 3 so, you will be getting this sorted
184
01:00:42,110 --> 01:00:49,110
so, you can think that is page 1 page 2 and
this is page 3. Now, if you have n elements
185
01:00:56,010 --> 01:01:01,610
how many changes will be there login failures?
186
01:01:01,610 --> 01:01:08,610
Now, in the i-th phase we are looking for
in the first phase you need 1comparator and
187
01:01:08,750 --> 01:01:15,750
n by 2 path this is 1comparator 1there are
n by 2 parts in log in phase log n-th phase,
188
01:01:21,720 --> 01:01:28,720
you need n log n plus 1comparators and 1path.
Now, you need to find out I need to find out
189
01:01:51,840 --> 01:01:58,840
what happens for the i-th phase can you tell
me in the i-th phase. How many parts are there
190
01:02:32,710 --> 01:02:37,100
number of parts in the i-th phase in the first
phase,
191
01:02:37,100 --> 01:02:37,660
How many parts in the second phase in the
i-th phase n upon 2 to the power I. And now,
192
01:02:37,660 --> 01:02:38,000
in the i-th phase and in a particular path
so, k-th path or a first path because they
193
01:02:38,000 --> 01:02:38,460
are chimerically distributed if you have 3
here can also here 3.
194
01:02:38,460 --> 01:02:45,460
So, I need to find out any 1 path how many
comparators are there, that will solve your
195
01:02:51,720 --> 01:02:58,720
problem in the i-th or in each part how many
elements are there in each part, in each part
196
01:02:58,780 --> 01:03:05,780
how many comparator elements are there number
of elements 2 to the power i. Very good if
197
01:03:05,820 --> 01:03:12,820
I know this 2 to the power i. What is the
number of comparators you need so, the number
198
01:03:23,460 --> 01:03:30,460
of comparators c 2 the power i is 2 to the
power i into i plus 1. So, in each part you
199
01:03:39,260 --> 01:03:45,080
need that many comparators agreed. So, you
need total number of comparators total number
200
01:03:45,080 --> 01:03:46,500
of comparators in i-th phase is one.
201
01:03:46,500 --> 01:03:49,700
So, clip pick in this part I need 3 comparators,
compare what is the total number this plus
202
01:03:49,700 --> 01:03:56,700
this so, tell you same thing you tell n upon
very good so, you have n upon 2 to the power
203
01:04:17,930 --> 01:04:24,930
i 2 to the power I, i plus 1that is your n
i plus n upon 2 to the power i again so, the
204
01:04:25,170 --> 01:04:27,980
total number of comparators you need total
number of comparators equals to summation
205
01:04:27,980 --> 01:04:34,980
n into i plus n by 2 to the power I, i is
1to log n. Now tell me the sum, what is the
206
01:04:38,250 --> 01:04:45,250
sum n log n plus tell me the value of this,
this is order n because this is 1 by n this
207
01:04:46,100 --> 01:04:47,230
becomes 11n by half.
208
01:04:47,230 --> 01:04:49,320
So, it is this is order n and this is so,
which i can write order n log 2n so, you obtain
209
01:04:49,320 --> 01:04:51,570
your cost by comparators number of comparators
is ordered n log squared n. Now, what is the
210
01:04:51,570 --> 01:04:51,950
total number of steps use 2log n, how did
you get in the i-th step in the first step
211
01:04:51,950 --> 01:04:53,300
first phase, first phase number of step is
1n-th log n-th phase number of step is log
212
01:04:53,300 --> 01:04:56,170
n plus 1i-th phase number of parallel steps
is log i plus 1.
213
01:04:56,170 --> 01:04:58,700
So, the total number of steps is equal to
summation over i equals to 1 to log n log
214
01:04:58,700 --> 01:05:05,700
i plus 1. Which is log n plus 1 divided by
2 plus log n by need not 2 log so, this gives
215
01:05:06,400 --> 01:05:12,010
you ordered log square n so, this is that
for merging this is for sorting. So, the cost
216
01:05:12,010 --> 01:05:18,960
of sorting network is ordered n log to the
power 4 n log lower bound of sorting algorithm
217
01:05:18,960 --> 01:05:21,020
is ordered n log n here it is n log term 4
n.
218
01:05:21,020 --> 01:05:22,680
So, log cube n act as aware form the cost
of cumulative now, can you read that what
219
01:05:22,680 --> 01:05:22,860
is the cost for algorithms are or in sorting
network in last class i covered n square log
220
01:05:22,860 --> 01:05:24,170
n and that was a more complex 1. You observe
that it forms the binarity connection. So,
221
01:05:24,170 --> 01:05:25,050
who is going were now, how many connection
you can have, also me problems are there but,
222
01:05:25,050 --> 01:05:25,930
here the it is a uniform structure comparators
are uniform in nature and this a clean diagram
223
01:05:25,930 --> 01:05:26,760
known he has some problem. But, the number
of comparators to many n log squared. See
224
01:05:26,760 --> 01:05:27,750
why line here you observe these part is not
be used when the data has been moved to this
225
01:05:27,750 --> 01:05:29,619
phase this comparators are either.
Now, what my point is that can you do some
226
01:05:29,619 --> 01:05:29,619
is same this structure and this structure
is same. I could have only this link has to
227
01:05:29,670 --> 01:05:29,730
that case that number of comparator should
be use and number of comparator should, you
228
01:05:29,730 --> 01:05:29,780
can reduce that cost should reduce what you
are increasing, see everything you converted
229
01:05:29,780 --> 01:05:31,360
you are increasing the complexity of the connection.
By using say zero the connection structure
230
01:05:31,360 --> 01:05:37,260
is this that data will come be coming from
this side and if it is 1the data will be coming
231
01:05:37,260 --> 01:05:38,190
from this side.
232
01:05:38,190 --> 01:05:45,190
Now, those type of manipulation you put so,
you have to work when and you see if it is
233
01:05:46,140 --> 01:05:47,250
possible. Can we reduce this by say log square
factor or even if it is a log factor. Let,
234
01:05:47,250 --> 01:05:54,250
us do it let, us see how it looks arises what
first phase it is 1 so, it is i he still thinking
235
01:06:10,160 --> 01:06:27,720
about that 1 be happy is it now, if it is
this is everything is you right yes it is
236
01:06:28,180 --> 01:06:42,680
i but, it’s not a matching first phase why
is come matching but, these is a original
237
01:06:47,760 --> 01:06:57,060
somewhere has been comparator , that 1why
it is log n here i do not k or k n plus 1there
238
01:07:08,260 --> 01:07:18,119
is another you are not attractive at this
time lets, prepare that should be clear in
239
01:07:18,119 --> 01:07:49,419
that case that the simple from 2n, 2n conversion
here only you have to wait and see you have
240
01:07:49,460 --> 01:07:56,780
to see that is should be cared. So, make the
correction from the conversion t 2n to t n
241
01:07:56,780 --> 01:08:02,340
here it should be t n instead of k n plus
one. So, you can consider this as you have
242
01:08:02,340 --> 01:08:09,310
to 1of the stamp paper problem that can you
use less number of comparator to have this
243
01:08:09,310 --> 01:08:16,310
odd even merging number networks. You can
define your operators also will not that you
244
01:08:18,400 --> 01:08:32,980
define now, for that you can take the help
of the art of computer programming Boolean
245
01:08:33,120 --> 01:08:39,720
shortage such type by there is a sorting network
minimum sort number of comparisons so you
246
01:08:40,580 --> 01:08:58,180
can use some of them or 1of them to find the
possible why 2elements for merging. Why 2
247
01:08:58,460 --> 01:09:05,460
why not 3 I have the very good sorting network
for 5 elements which take 7 7 comparisons
248
01:09:07,800 --> 01:09:14,800
why not 5 5 times so but, you have to do the
little study on that and then you can design.