579 What would be the |
579 What would be the |
580 derivative of one? |
580 derivative of one? |
581 |
581 |
582 126 |
582 126 |
583 00:06:32,030 --> 00:06:36,140 |
583 00:06:32,030 --> 00:06:36,140 |
584 So the derivative of c of one. |
584 So the derivative of c of 1 |
585 |
585 |
586 127 |
586 127 |
587 00:06:36,140 --> 00:06:38,990 |
587 00:06:36,140 --> 00:06:38,990 |
588 Peaches defined as 0. |
588 would be defined as 0. |
589 |
589 |
590 128 |
590 128 |
591 00:06:38,990 --> 00:06:41,465 |
591 00:06:38,990 --> 00:06:41,465 |
592 Okay, fair enough. |
592 Okay, fair enough. |
593 |
593 |
594 129 |
594 129 |
595 00:06:41,465 --> 00:06:44,960 |
595 00:06:41,465 --> 00:06:44,960 |
596 If he have any cross one, |
596 If he have n = 1, |
597 |
597 |
598 130 |
598 130 |
599 00:06:44,960 --> 00:06:48,125 |
599 00:06:44,960 --> 00:06:48,125 |
600 then we just have one copy |
600 then we just have one copy |
601 of this regular expression. |
601 of this regular expression. |
602 |
602 |
603 131 |
603 131 |
604 00:06:48,125 --> 00:06:50,120 |
604 00:06:48,125 --> 00:06:50,120 |
605 So there's not much as we can do. |
605 So there's not much else we can do. |
606 |
606 |
607 132 |
607 132 |
608 00:06:50,120 --> 00:06:53,735 |
608 00:06:50,120 --> 00:06:53,735 |
609 We would have to calculate |
609 We would have to calculate |
610 the derivative of air are. |
610 the derivative of r. |
611 |
611 |
612 133 |
612 133 |
613 00:06:53,735 --> 00:06:57,395 |
613 00:06:53,735 --> 00:06:57,395 |
614 Now in the n equals two case. |
614 Now in the n = 2 case, |
615 |
615 |
616 134 |
616 134 |
617 00:06:57,395 --> 00:07:00,245 |
617 00:06:57,395 --> 00:07:00,245 |
618 That would mean we |
618 that would mean we |
619 have two copies of |
619 have two copies of r. |
620 |
620 |
621 135 |
621 135 |
622 00:07:00,245 --> 00:07:03,425 |
622 00:07:00,245 --> 00:07:03,425 |
623 R. And they would be a sequence. |
623 And they would be a sequence. |
624 |
624 |
625 136 |
625 136 |
626 00:07:03,425 --> 00:07:07,775 |
626 00:07:03,425 --> 00:07:07,775 |
627 How would be the derivative C of |
627 How would be the derivative c of |
628 |
628 |
629 137 |
629 137 |
630 00:07:07,775 --> 00:07:10,340 |
630 00:07:07,775 --> 00:07:10,340 |
631 R four by R be |
631 r followed by r be |
632 |
632 |
633 138 |
633 138 |
634 00:07:10,340 --> 00:07:13,265 |
634 00:07:10,340 --> 00:07:13,265 |
635 defined where we would |
635 defined? Well we would |
636 look up the definition. |
636 look up the definition. |
637 |
637 |
638 139 |
638 139 |
639 00:07:13,265 --> 00:07:15,470 |
639 00:07:13,265 --> 00:07:15,470 |
640 And it would say that's |
640 And it would say that's |
641 the complicated case |
641 the complicated case, |
642 |
642 |
643 140 |
643 140 |
644 00:07:15,470 --> 00:07:16,760 |
644 00:07:15,470 --> 00:07:16,760 |
645 d sequence or |
645 the sequence. |
646 |
646 |
647 141 |
647 141 |
648 00:07:16,760 --> 00:07:21,875 |
648 00:07:16,760 --> 00:07:21,875 |
649 if null a bowl of R, |
649 If nullable of r, |
650 |
650 |
651 142 |
651 142 |
652 00:07:21,875 --> 00:07:25,250 |
652 00:07:21,875 --> 00:07:25,250 |
653 Then the most complicated case. |
653 then the more complicated case, |
654 |
654 |
655 143 |
655 143 |
656 00:07:25,250 --> 00:07:28,225 |
656 00:07:25,250 --> 00:07:28,225 |
657 Else, That's the easy |
657 else, that's the easy |
658 case that would be |
658 case, that would be |
659 |
659 |
660 144 |
660 144 |
661 00:07:28,225 --> 00:07:32,660 |
661 00:07:28,225 --> 00:07:32,660 |
662 derivative of c of R four |
662 derivative of c of r, followed |
663 |
663 |
664 145 |
664 145 |
665 00:07:32,660 --> 00:07:35,540 |
665 00:07:32,660 --> 00:07:35,540 |
666 by R. And then I |
666 by r. And then I just have to copy |
667 just have to copy |
|
668 |
667 |
669 146 |
668 146 |
670 00:07:35,540 --> 00:07:40,775 |
669 00:07:35,540 --> 00:07:40,775 |
671 that derivative of C |
670 that derivative of c |
672 of four by r here. |
671 of r followed by r here. |
673 |
672 |
674 147 |
673 147 |
675 00:07:40,775 --> 00:07:43,130 |
674 00:07:40,775 --> 00:07:43,130 |
676 But in this case I have also |
675 But in this case I have also |
677 |
676 |
680 the alternative derivative |
679 the alternative derivative |
681 of c of r. And from that, |
680 of c of r. And from that, |
682 |
681 |
683 149 |
682 149 |
684 00:07:51,145 --> 00:07:55,030 |
683 00:07:51,145 --> 00:07:55,030 |
685 it looks like we can |
684 it looks like we can't |
686 do much better than |
685 do much better than |
687 |
686 |
688 150 |
687 150 |
689 00:07:55,030 --> 00:07:58,390 |
688 00:07:55,030 --> 00:07:58,390 |
690 that unless we do |
689 that, unless we do |
691 |
690 |
692 151 |
691 151 |
693 00:07:58,390 --> 00:08:02,560 |
692 00:07:58,390 --> 00:08:02,560 |
694 a little bit of magic and the |
693 a little bit of magic and the |
695 magic to do with this case. |
694 magic has to do with this case. |
696 |
695 |
697 152 |
696 152 |
698 00:08:02,560 --> 00:08:07,420 |
697 00:08:02,560 --> 00:08:07,420 |
699 So let me look at this |
698 So let me look at this |
700 case a bit more closely. |
699 case a bit more closely. |
717 00:08:16,945 --> 00:08:18,550 |
716 00:08:16,945 --> 00:08:18,550 |
718 And this was defined as |
717 And this was defined as |
719 |
718 |
720 157 |
719 157 |
721 00:08:18,550 --> 00:08:20,680 |
720 00:08:18,550 --> 00:08:20,680 |
722 this sequence work |
721 this sequence regular |
723 expression R followed |
722 expression r followed by r. |
724 |
723 |
725 158 |
724 158 |
726 00:08:20,680 --> 00:08:23,080 |
725 00:08:20,680 --> 00:08:23,080 |
727 by r. And the question was, |
726 And the question was, |
728 |
727 |
729 159 |
728 159 |
730 00:08:23,080 --> 00:08:26,365 |
729 00:08:23,080 --> 00:08:26,365 |
731 can we somehow make sense |
730 can we somehow make sense |
732 out of this derivative |
731 out of this derivative |
792 decide in which branch we are. |
791 decide in which branch we are. |
793 |
792 |
794 173 |
793 173 |
795 00:09:08,330 --> 00:09:10,580 |
794 00:09:08,330 --> 00:09:10,580 |
796 We don't have to |
795 We don't have to |
797 calculate your now, |
796 calculate nullable, |
798 |
797 |
799 174 |
798 174 |
800 00:09:10,580 --> 00:09:13,880 |
799 00:09:10,580 --> 00:09:13,880 |
801 but we can just replace |
800 we can just replace |
802 it by this expression. |
801 it by this expression. |
803 |
802 |
804 175 |
803 175 |
805 00:09:13,880 --> 00:09:16,670 |
804 00:09:13,880 --> 00:09:16,670 |
806 So if we can |
805 So if we can |
807 substantiate that claim, |
806 substantiate that claim, |
808 |
807 |
809 176 |
808 176 |
810 00:09:16,670 --> 00:09:19,860 |
809 00:09:16,670 --> 00:09:19,860 |
811 that will be definitely |
810 that will be definitely |
812 good file algorithm. |
811 good our algorithm. |
813 |
812 |
814 177 |
813 177 |
815 00:09:20,140 --> 00:09:22,775 |
814 00:09:20,140 --> 00:09:22,775 |
816 And to substantiate that, |
815 And to substantiate that, |
817 |
816 |
879 Let's see what we can do. |
878 Let's see what we can do. |
880 |
879 |
881 192 |
880 192 |
882 00:10:05,945 --> 00:10:10,160 |
881 00:10:05,945 --> 00:10:10,160 |
883 So the first thing |
882 So the first thing |
884 actually is we multiplying |
883 actually is we're multiplying |
885 |
884 |
886 193 |
885 193 |
887 00:10:10,160 --> 00:10:16,595 |
886 00:10:10,160 --> 00:10:16,595 |
888 this right hand side of the |
887 this right hand side of the |
889 alternative is times one. |
888 alternative with times 1. |
890 |
889 |
891 194 |
890 194 |
892 00:10:16,595 --> 00:10:19,700 |
891 00:10:16,595 --> 00:10:19,700 |
893 We can do that |
892 We can do that |
894 because this does not |
893 because this does not |
895 |
894 |
896 195 |
895 195 |
897 00:10:19,700 --> 00:10:23,090 |
896 00:10:19,700 --> 00:10:23,090 |
898 change which strings this |
897 change which strings this |
899 work expression can match. |
898 regular expression can match. |
900 |
899 |
901 196 |
900 196 |
902 00:10:23,090 --> 00:10:25,685 |
901 00:10:23,090 --> 00:10:25,685 |
903 Remember we even had it |
902 Remember we even had it |
904 as a simplification row, |
903 as a simplification rule, |
905 |
904 |
906 197 |
905 197 |
907 00:10:25,685 --> 00:10:27,425 |
906 00:10:25,685 --> 00:10:27,425 |
908 just in this case B, |
907 just in this case we |
909 |
908 |
910 198 |
909 198 |
911 00:10:27,425 --> 00:10:29,705 |
910 00:10:27,425 --> 00:10:29,705 |
912 don't apply it as a |
911 don't apply it as a |
913 simplification will |
912 simplification rule, |
914 |
913 |
915 199 |
914 199 |
916 00:10:29,705 --> 00:10:31,310 |
915 00:10:29,705 --> 00:10:31,310 |
917 actually make this |
916 actually make this |
918 work expression |
917 regular expression |
919 |
918 |
920 200 |
919 200 |
921 00:10:31,310 --> 00:10:32,720 |
920 00:10:31,310 --> 00:10:32,720 |
922 a bit more complicated. |
921 a bit more complicated. |
923 |
922 |
924 201 |
923 201 |
925 00:10:32,720 --> 00:10:34,910 |
924 00:10:32,720 --> 00:10:34,910 |
926 But times one doesn't make |
925 But times 1 doesn't make |
927 |
926 |
928 202 |
927 202 |
929 00:10:34,910 --> 00:10:37,820 |
928 00:10:34,910 --> 00:10:37,820 |
930 a difference because it |
929 a difference because it |
931 means the end of the string, |
930 means at the end of a string, |
932 |
931 |
933 203 |
932 203 |
934 00:10:37,820 --> 00:10:40,070 |
933 00:10:37,820 --> 00:10:40,070 |
935 we still want to match |
934 we still want to match |
936 the empty string. |
935 the empty string. |
976 And I'm inside the parentheses |
975 And I'm inside the parentheses |
977 is left with that. |
976 is left with that. |
978 |
977 |
979 213 |
978 213 |
980 00:11:06,320 --> 00:11:09,245 |
979 00:11:06,320 --> 00:11:09,245 |
981 So now I have r plus one. |
980 So now I have r + 1. |
982 |
981 |
983 214 |
982 214 |
984 00:11:09,245 --> 00:11:13,055 |
983 00:11:09,245 --> 00:11:13,055 |
985 Usually we cannot |
984 Usually we cannot |
986 simplify r plus one. |
985 simplify r + 1. |
987 |
986 |
988 215 |
987 215 |
989 00:11:13,055 --> 00:11:15,530 |
988 00:11:13,055 --> 00:11:15,530 |
990 If it had been R |
989 If it had been r + 0, then yes, |
991 plus 0, then yes, |
|
992 |
990 |
993 216 |
991 216 |
994 00:11:15,530 --> 00:11:18,665 |
992 00:11:15,530 --> 00:11:18,665 |
995 we could have got rid of the CRO. |
993 we could have got rid of the 0. |
996 |
994 |
997 217 |
995 217 |
998 00:11:18,665 --> 00:11:21,590 |
996 00:11:18,665 --> 00:11:21,590 |
999 Plus one often |
997 But this + 1 often |
1000 makes a difference, |
998 makes a difference, |
1001 |
999 |
1002 218 |
1000 218 |
1003 00:11:21,590 --> 00:11:22,970 |
1001 00:11:21,590 --> 00:11:22,970 |
1004 but not in our case. |
1002 but not in our case. |
1005 |
1003 |
1006 219 |
1004 219 |
1007 00:11:22,970 --> 00:11:25,940 |
1005 00:11:22,970 --> 00:11:25,940 |
1008 Remember, we know that |
1006 Remember, we know that |
1009 this R is nullable, |
1007 this r is nullable, |
1010 |
1008 |
1011 220 |
1009 220 |
1012 00:11:25,940 --> 00:11:29,840 |
1010 00:11:25,940 --> 00:11:29,840 |
1013 so on its own can already |
1011 so on its own can already |
1014 match the empty string. |
1012 match the empty string. |
1026 00:11:35,300 --> 00:11:37,070 |
1024 00:11:35,300 --> 00:11:37,070 |
1027 Okay, and so now we have |
1025 Okay, and so now we have |
1028 |
1026 |
1029 224 |
1027 224 |
1030 00:11:37,070 --> 00:11:40,535 |
1028 00:11:37,070 --> 00:11:40,535 |
1031 a much simpler wound |
1029 a much simpler equivalent |
1032 reg expression. |
1030 regular expression. |
1033 |
1031 |
1034 225 |
1032 225 |
1035 00:11:40,535 --> 00:11:44,285 |
1033 00:11:40,535 --> 00:11:44,285 |
1036 And this actually helps a |
1034 And this actually helps a |
1037 lot for our if condition. |
1035 lot for our if-condition. |
1038 |
1036 |
1039 226 |
1037 226 |
1040 00:11:44,285 --> 00:11:46,925 |
1038 00:11:44,285 --> 00:11:46,925 |
1041 Look, this was the |
1039 Look, this was the |
1042 original if condition |
1040 original if-condition |
1043 |
1041 |
1044 227 |
1042 227 |
1045 00:11:46,925 --> 00:11:50,270 |
1043 00:11:46,925 --> 00:11:50,270 |
1046 and this is direct expression |
1044 and this is the regular expression |
1047 h. We just simplified. |
1045 we just simplified. |
1048 |
1046 |
1049 228 |
1047 228 |
1050 00:11:50,270 --> 00:11:53,105 |
1048 00:11:50,270 --> 00:11:53,105 |
1051 If we replace it with this one, |
1049 If we replace it with this one, |
1052 |
1050 |
1101 So let's take stock |
1099 So let's take stock |
1102 what we have so far. |
1100 what we have so far. |
1103 |
1101 |
1104 240 |
1102 240 |
1105 00:12:24,170 --> 00:12:26,915 |
1103 00:12:24,170 --> 00:12:26,915 |
1106 So we know India CEO case, |
1104 So we know in the 0-case, |
1107 |
1105 |
1108 241 |
1106 241 |
1109 00:12:26,915 --> 00:12:30,920 |
1107 00:12:26,915 --> 00:12:30,920 |
1110 the derivative needs |
1108 the derivative needs |
1111 to be defined as 0. |
1109 to be defined as 0. |
1112 |
1110 |
1113 242 |
1111 242 |
1114 00:12:30,920 --> 00:12:33,095 |
1112 00:12:30,920 --> 00:12:33,095 |
1115 So because we define this |
1113 Because we define this |
1116 |
1114 |
1117 243 |
1115 243 |
1118 00:12:33,095 --> 00:12:36,785 |
1116 00:12:33,095 --> 00:12:36,785 |
1119 and times as one, |
1117 n-times as one, |
1120 the derivative is 0. |
1118 the derivative is 0. |
1121 |
1119 |
1122 244 |
1120 244 |
1123 00:12:36,785 --> 00:12:39,889 |
1121 00:12:36,785 --> 00:12:39,889 |
1124 For chest r, this will |
1122 For just r, this will |
1125 be the derivative. |
1123 be the derivative. |
1126 |
1124 |
1127 245 |
1125 245 |
1128 00:12:39,889 --> 00:12:42,170 |
1126 00:12:39,889 --> 00:12:42,170 |
1129 And we can't do any |
1127 And we can't do any |
1130 better than that |
1128 better than that. |
1131 |
1129 |
1132 246 |
1130 246 |
1133 00:12:42,170 --> 00:12:45,620 |
1131 00:12:42,170 --> 00:12:45,620 |
1134 for our followed by |
1132 For r followed by r, as we |
1135 RB just found out. |
1133 just found out |
1136 |
1134 |
1137 247 |
1135 247 |
1138 00:12:45,620 --> 00:12:47,270 |
1136 00:12:45,620 --> 00:12:47,270 |
1139 Actually it is quite simple. |
1137 actually it is quite simple |
1140 |
1138 |
1141 248 |
1139 248 |
1142 00:12:47,270 --> 00:12:51,410 |
1140 00:12:47,270 --> 00:12:51,410 |
1143 Reg expression is equivalent |
1141 regular expression is equivalent |
1144 to the derivative. |
1142 to the derivative. |
1145 |
1143 |
1146 249 |
1144 249 |
1147 00:12:51,410 --> 00:12:53,870 |
1145 00:12:51,410 --> 00:12:53,870 |
1148 Now, we have to continue with |
1146 Now, we have to continue with |
1183 00:13:16,400 --> 00:13:18,275 |
1181 00:13:16,400 --> 00:13:18,275 |
1184 we end up with this. |
1182 we end up with this. |
1185 |
1183 |
1186 258 |
1184 258 |
1187 00:13:18,275 --> 00:13:21,290 |
1185 00:13:18,275 --> 00:13:21,290 |
1188 Because then what we have is. |
1186 Because then what we have is this. |
1189 |
1187 |
1190 259 |
1188 259 |
1191 00:13:21,290 --> 00:13:25,370 |
1189 00:13:21,290 --> 00:13:25,370 |
1192 We can define our |
1190 We can define our |
1193 nullable for n times |
1191 nullable for n-times |
1194 |
1192 |
1195 260 |
1193 260 |
1196 00:13:25,370 --> 00:13:31,025 |
1194 00:13:25,370 --> 00:13:31,025 |
1197 s. If any cross 0 then |
1195 as if n = 0 then |
1198 true as nullable. |
1196 true, else nullable r. |
1199 |
1197 |
1200 261 |
1198 261 |
1201 00:13:31,025 --> 00:13:33,875 |
1199 00:13:31,025 --> 00:13:33,875 |
1202 And for the derivative, |
1200 And for the derivative, |
1203 |
1201 |
1206 we can save if n is equal to 0, |
1204 we can save if n is equal to 0, |
1207 |
1205 |
1208 263 |
1206 263 |
1209 00:13:37,190 --> 00:13:40,235 |
1207 00:13:37,190 --> 00:13:40,235 |
1210 then we return the |
1208 then we return the |
1211 Sierra reg expression. |
1209 0 regular expression. |
1212 |
1210 |
1213 264 |
1211 264 |
1214 00:13:40,235 --> 00:13:43,295 |
1212 00:13:40,235 --> 00:13:43,295 |
1215 Otherwise, as you can see |
1213 Otherwise, as you can see |
1216 from this pattern here, |
1214 from this pattern here, |
1217 |
1215 |
1218 265 |
1216 265 |
1219 00:13:43,295 --> 00:13:50,735 |
1217 00:13:43,295 --> 00:13:50,735 |
1220 it would be derivative of |
1218 it would be derivative of |
1221 c r four by r n minus one. |
1219 c r followed by r{n-1}. |
1222 |
1220 |
1223 266 |
1221 266 |
1224 00:13:50,735 --> 00:13:54,770 |
1222 00:13:50,735 --> 00:13:54,770 |
1225 Okay? And the only |
1223 Okay? And the only |
1226 |
1224 |
1227 267 |
1225 267 |
1228 00:13:54,770 --> 00:13:56,330 |
1226 00:13:54,770 --> 00:13:56,330 |
1229 thing we have to make choice that |
1227 thing we have to make csure is that |
1230 |
1228 |
1231 268 |
1229 268 |
1232 00:13:56,330 --> 00:13:58,175 |
1230 00:13:56,330 --> 00:13:58,175 |
1233 this pattern actually holds. |
1231 this pattern actually holds. |
1234 |
1232 |
1259 We can just unfold |
1257 We can just unfold |
1260 again the definition. |
1258 again the definition. |
1261 |
1259 |
1262 275 |
1260 275 |
1263 00:14:14,245 --> 00:14:16,930 |
1261 00:14:14,245 --> 00:14:16,930 |
1264 So we would ask if I is nullable, |
1262 So we would ask if r is nullable, |
1265 |
1263 |
1266 276 |
1264 276 |
1267 00:14:16,930 --> 00:14:19,765 |
1265 00:14:16,930 --> 00:14:19,765 |
1268 then we have this if branch. |
1266 then we have this if branch. |
1269 |
1267 |
1270 277 |
1268 277 |
1271 00:14:19,765 --> 00:14:23,905 |
1269 00:14:19,765 --> 00:14:23,905 |
1272 And if i is not nullable |
1270 And if r is not nullable, |
1273 or we have this as branch. |
1271 we have this else branch. |
1274 |
1272 |
1275 278 |
1273 278 |
1276 00:14:23,905 --> 00:14:27,010 |
1274 00:14:23,905 --> 00:14:27,010 |
1277 Okay? What can we do here? |
1275 Okay? What can we do here? |
1278 |
1276 |
1458 I'm now back in our |
1455 I'm now back in our |
1459 implementation. |
1456 implementation. |
1460 |
1457 |
1461 318 |
1458 318 |
1462 00:16:16,250 --> 00:16:20,660 |
1459 00:16:16,250 --> 00:16:20,660 |
1463 In this Reto, said We have |
1460 In this re2.sc, we said we have |
1464 this explicit constructor now |
1461 this explicit constructor |
1465 |
1462 |
1466 319 |
1463 319 |
1467 00:16:20,660 --> 00:16:25,535 |
1464 00:16:20,660 --> 00:16:25,535 |
1468 for n times b can now fill |
1465 for n-times. We can now fill |
1469 in the cases for nullable. |
1466 in the cases for nullable. |
1470 |
1467 |
1471 320 |
1468 320 |
1472 00:16:25,535 --> 00:16:27,635 |
1469 00:16:25,535 --> 00:16:27,635 |
1473 So if we have R in times, |
1470 So if we have r n-times, |
1474 |
1471 |
1475 321 |
1472 321 |
1476 00:16:27,635 --> 00:16:30,995 |
1473 00:16:27,635 --> 00:16:30,995 |
1477 if this n is equal to |
1474 if this n is equal to |
1478 0, we return true. |
1475 0, we return true. |
1479 |
1476 |
1480 322 |
1477 322 |
1481 00:16:30,995 --> 00:16:34,190 |
1478 00:16:30,995 --> 00:16:34,190 |
1482 Otherwise we have to test |
1479 Otherwise we have to test |
1483 whether eyes nullable. |
1480 whether r is nullable. |
1484 |
1481 |
1485 323 |
1482 323 |
1486 00:16:34,190 --> 00:16:37,565 |
1483 00:16:34,190 --> 00:16:37,565 |
1487 And in the derivative case, oi, |
1484 And in the derivative case, |
1488 |
1485 |
1489 324 |
1486 324 |
1490 00:16:37,565 --> 00:16:40,339 |
1487 00:16:37,565 --> 00:16:40,339 |
1491 if this n is equal to 0, |
1488 if this n is equal to 0, |
1492 |
1489 |
1493 325 |
1490 325 |
1494 00:16:40,339 --> 00:16:43,564 |
1491 00:16:40,339 --> 00:16:43,564 |
1495 the return this 0 |
1492 the return this 0 |
1496 wreck expression. |
1493 regular expression. |
1497 |
1494 |
1498 326 |
1495 326 |
1499 00:16:43,564 --> 00:16:46,700 |
1496 00:16:43,564 --> 00:16:46,700 |
1500 Otherwise we return the |
1497 Otherwise we return the |
1501 sequence of the derivative |
1498 sequence of the derivative |
1502 |
1499 |
1503 327 |
1500 327 |
1504 00:16:46,700 --> 00:16:50,270 |
1501 00:16:46,700 --> 00:16:50,270 |
1505 of psi of r four by n times of r, |
1502 of c of r followed by n times of r, |
1506 |
1503 |
1507 328 |
1504 328 |
1508 00:16:50,270 --> 00:16:54,545 |
1505 00:16:50,270 --> 00:16:54,545 |
1509 but n minus one times and |
1506 but n minus one times, and |
1510 everything else stays the same. |
1507 everything else stays the same. |
1511 |
1508 |
1512 329 |
1509 329 |
1513 00:16:54,545 --> 00:16:56,510 |
1510 00:16:54,545 --> 00:16:56,510 |
1514 Here's the function for strings, |
1511 Here's the function for strings, |
1531 00:17:04,820 --> 00:17:06,050 |
1528 00:17:04,820 --> 00:17:06,050 |
1532 we haven't done anything about |
1529 we haven't done anything about |
1533 |
1530 |
1534 334 |
1531 334 |
1535 00:17:06,050 --> 00:17:08,090 |
1532 00:17:06,050 --> 00:17:08,090 |
1536 the optional record |
1533 the optional regular |
1537 expression yet. |
1534 expression yet. |
1538 |
1535 |
1539 335 |
1536 335 |
1540 00:17:08,090 --> 00:17:10,670 |
1537 00:17:08,090 --> 00:17:10,670 |
1541 And we have now at this |
1538 And we have now this |
1542 |
1539 |
1543 336 |
1540 336 |
1544 00:17:10,670 --> 00:17:13,250 |
1541 00:17:10,670 --> 00:17:13,250 |
1545 either warm and evil |
1542 EVIL1 and EVIL2 |
1546 2-break expression. |
1543 regular expression. |
1547 |
1544 |
1548 337 |
1545 337 |
1549 00:17:13,250 --> 00:17:15,290 |
1546 00:17:13,250 --> 00:17:15,290 |
1550 And let's test it. And let's be |
1547 And let's test it. And let's be |
1551 |
1548 |
1552 338 |
1549 338 |
1553 00:17:15,290 --> 00:17:17,000 |
1550 00:17:15,290 --> 00:17:17,000 |
1554 a bit more ambitious. |
1551 a bit more ambitious. |
1555 Be testing it. |
1552 We're testing it with |
1556 |
1553 |
1557 339 |
1554 339 |
1558 00:17:17,000 --> 00:17:20,315 |
1555 00:17:17,000 --> 00:17:20,315 |
1559 The strings between 01000 |
1556 strings between 0 and 1000 |
1560 |
1557 |
1561 340 |
1558 340 |
1562 00:17:20,315 --> 00:17:22,580 |
1559 00:17:20,315 --> 00:17:22,580 |
1563 and let's see what the time say. |
1560 and let's see what the time say. |
1564 |
1561 |
1565 341 |
1562 341 |
1566 00:17:22,580 --> 00:17:26,210 |
1563 00:17:22,580 --> 00:17:26,210 |
1567 I'm testing this again |
1564 I'm testing this again |
1568 inside the ammonite rebel. |
1565 inside the Ammonite REPL. |
1569 |
1566 |
1570 342 |
1567 342 |
1571 00:17:26,210 --> 00:17:30,180 |
1568 00:17:26,210 --> 00:17:30,180 |
1572 And you'll see it should |
1569 And you'll see it should |
1573 be now much quicker. |
1570 be now much quicker. |
1578 down also around 600. |
1575 down also around 600. |
1579 |
1576 |
1580 344 |
1577 344 |
1581 00:17:34,640 --> 00:17:40,490 |
1578 00:17:34,640 --> 00:17:40,490 |
1582 700 needs two seconds, |
1579 700 needs two seconds, |
1583 three seconds, 4800. |
1580 three seconds for 800. |
1584 |
1581 |
1585 345 |
1582 345 |
1586 00:17:40,490 --> 00:17:43,940 |
1583 00:17:40,490 --> 00:17:43,940 |
1587 Let's see about it |
1584 Let's see what it |
1588 needs 4 thousand. |
1585 needs for one thousand? |
1589 |
1586 |
1590 346 |
1587 346 |
1591 00:17:43,940 --> 00:17:47,435 |
1588 00:17:43,940 --> 00:17:47,435 |
1592 But you have to remember |
1589 But you have to remember |
1593 Ruby and Python. |
1590 Ruby and Python |
1594 |
1591 |
1595 347 |
1592 347 |
1596 00:17:47,435 --> 00:17:51,530 |
1593 00:17:47,435 --> 00:17:51,530 |
1597 They needed half a |
1594 needed half a |
1598 minute to just 43 TAs. |
1595 minute for just 30 a's. |
1599 |
1596 |
1600 348 |
1597 348 |
1601 00:17:51,530 --> 00:17:54,485 |
1598 00:17:51,530 --> 00:17:54,485 |
1602 We need a little bit |
1599 We need a little bit |
1603 more than six seconds, |
1600 more than six seconds, |
1606 00:17:54,485 --> 00:17:57,110 |
1603 00:17:54,485 --> 00:17:57,110 |
1607 but we are processing a string of |
1604 but we are processing a string of |
1608 |
1605 |
1609 350 |
1606 350 |
1610 00:17:57,110 --> 00:18:00,575 |
1607 00:17:57,110 --> 00:18:00,575 |
1611 1000 days so that success. |
1608 1000 a's. So that success. |
1612 |
1609 |
1613 351 |
1610 351 |
1614 00:18:00,575 --> 00:18:04,775 |
1611 00:18:00,575 --> 00:18:04,775 |
1615 So this speed is also explained |
1612 This speed is also explained |
1616 if you look at the sizes. |
1613 if you look at the sizes. |
1617 |
1614 |
1618 352 |
1615 352 |
1619 00:18:04,775 --> 00:18:08,975 |
1616 00:18:04,775 --> 00:18:08,975 |
1620 Since we now have this explicit |
1617 Since we now have this explicit |
1621 and times constructor, |
1618 n-times constructor, |
1622 |
1619 |
1623 353 |
1620 353 |
1624 00:18:08,975 --> 00:18:11,930 |
1621 00:18:08,975 --> 00:18:11,930 |
1625 it doesn't really matter |
1622 it doesn't really matter |
1626 how big this n is. |
1623 how big this n is. |
1627 |
1624 |
1628 354 |
1625 354 |
1629 00:18:11,930 --> 00:18:14,540 |
1626 00:18:11,930 --> 00:18:14,540 |
1630 This evil one reg |
1627 This EVIL1 regular |
1631 expression will always be |
1628 expression will always be |
1632 |
1629 |
1633 355 |
1630 355 |
1634 00:18:14,540 --> 00:18:17,195 |
1631 00:18:14,540 --> 00:18:17,195 |
1635 of this size seven, |
1632 of this size seven, at |
1636 the beginning. |
1633 the beginning. |
1637 |
1634 |
1638 356 |
1635 356 |
1639 00:18:17,195 --> 00:18:20,315 |
1636 00:18:17,195 --> 00:18:20,315 |
1640 And you can also see if you |
1637 And you can also see if you |
1649 but much more moderately. |
1646 but much more moderately. |
1650 |
1647 |
1651 359 |
1648 359 |
1652 00:18:24,740 --> 00:18:28,100 |
1649 00:18:24,740 --> 00:18:28,100 |
1653 And let's try out this |
1650 And let's try out this |
1654 example, this 20 a. |
1651 example with 20 a's. |
1655 |
1652 |
1656 360 |
1653 360 |
1657 00:18:28,100 --> 00:18:31,685 |
1654 00:18:28,100 --> 00:18:31,685 |
1658 So we build the derivative |
1655 So we build the derivative |
1659 according to 20 character A's. |
1656 according to 20 character a's. |
1660 |
1657 |
1661 361 |
1658 361 |
1662 00:18:31,685 --> 00:18:33,890 |
1659 00:18:31,685 --> 00:18:33,890 |
1663 In the earlier example, |
1660 In the earlier example, |
1664 |
1661 |
1665 362 |
1662 362 |
1666 00:18:33,890 --> 00:18:35,780 |
1663 00:18:33,890 --> 00:18:35,780 |
1667 we ended up this a |
1664 we ended up with a |
1668 wreck expression which |
1665 regular expression that |
1669 |
1666 |
1670 363 |
1667 363 |
1671 00:18:35,780 --> 00:18:37,895 |
1668 00:18:35,780 --> 00:18:37,895 |
1672 had like 8 million plus nodes. |
1669 had like 8 million plus nodes. |
1673 |
1670 |
1689 all the calculations |
1686 all the calculations |
1690 would be much quicker. |
1687 would be much quicker. |
1691 |
1688 |
1692 368 |
1689 368 |
1693 00:18:47,165 --> 00:18:49,550 |
1690 00:18:47,165 --> 00:18:49,550 |
1694 So yeah, there's |
1691 So yeah, the Brzozowski |
1695 |
1692 |
1696 369 |
1693 369 |
1697 00:18:49,550 --> 00:18:52,205 |
1694 00:18:49,550 --> 00:18:52,205 |
1698 this push off CKY algorithm |
1695 algorithm |
1699 and this improvement. |
1696 and with this improvement, |
1700 |
1697 |
1701 370 |
1698 370 |
1702 00:18:52,205 --> 00:18:54,890 |
1699 00:18:52,205 --> 00:18:54,890 |
1703 We're now running |
1700 we're now running |
1704 circles around Ruby and |
1701 circles around Ruby and |
1705 |
1702 |
1706 371 |
1703 371 |
1707 00:18:54,890 --> 00:18:58,445 |
1704 00:18:54,890 --> 00:18:58,445 |
1708 Python because they're just |
1705 Python because they're just |