1 00:00:00,580 --> 00:00:05,770 The first operation we are going to learn is our get operation here. 2 00:00:05,770 --> 00:00:13,930 So get operation, which we will develop this get method for our fetching an item to linked list class. 3 00:00:13,930 --> 00:00:15,160 So let's get started. 4 00:00:15,160 --> 00:00:18,610 My name is Typhoon and welcome to another lecture of our course. 5 00:00:32,270 --> 00:00:38,900 So the first operation we are going to learn is get, as I said here, so it will return. 6 00:00:38,900 --> 00:00:41,540 So actually, let's delete all of this. 7 00:00:41,570 --> 00:00:42,590 Delete, delete. 8 00:00:42,590 --> 00:00:44,660 So it will return. 9 00:00:46,190 --> 00:00:46,640 Here. 10 00:00:46,640 --> 00:00:48,110 This is our get. 11 00:00:49,850 --> 00:00:56,270 And this jet operation here will return the node here. 12 00:00:56,270 --> 00:00:59,270 So the node will return the node. 13 00:00:59,300 --> 00:01:07,520 So if this node, if the selected index is out of bounds, then it will return the null here. 14 00:01:07,730 --> 00:01:11,690 So then it will return null. 15 00:01:14,300 --> 00:01:17,760 So let's get started with developing our application now. 16 00:01:17,780 --> 00:01:20,060 Firstly, let's make it a bit. 17 00:01:20,890 --> 00:01:21,490 Here. 18 00:01:22,670 --> 00:01:23,060 Oops. 19 00:01:26,300 --> 00:01:27,050 Here. 20 00:01:27,560 --> 00:01:30,170 So now we're going to develop our application. 21 00:01:31,320 --> 00:01:38,430 So after the our template linked list here under the linked list here, we will develop something. 22 00:01:38,430 --> 00:01:41,300 So we will create first created um, template. 23 00:01:41,310 --> 00:01:50,340 The type name is going to be type name is going to be T again type name T and here we will develop the 24 00:01:50,340 --> 00:01:52,680 node class T here the. 25 00:01:53,670 --> 00:01:55,480 Well, this is going to be linked List. 26 00:01:55,500 --> 00:01:57,180 Linked list. 27 00:01:57,960 --> 00:02:00,120 And here we will develop the get method. 28 00:02:00,120 --> 00:02:02,340 So get index. 29 00:02:03,000 --> 00:02:08,300 So here we will firstly check if the index is out of bounds or not. 30 00:02:08,310 --> 00:02:11,760 In order to do that, we will create a if condition. 31 00:02:11,760 --> 00:02:24,300 So if our index is less than zero, index is less than zero or is index is greater than my count, then 32 00:02:24,300 --> 00:02:26,070 return null. 33 00:02:27,090 --> 00:02:30,060 So as I as we wrote here. 34 00:02:30,060 --> 00:02:32,220 So it will return null here. 35 00:02:32,220 --> 00:02:38,370 So in this case our null statement, the newly returning code is done here. 36 00:02:38,970 --> 00:02:41,430 Also, we created our get here. 37 00:02:41,910 --> 00:02:46,630 So now we just need to return a node if everything is okay. 38 00:02:46,650 --> 00:02:51,000 So here after the if we will start from the heat here. 39 00:02:51,000 --> 00:02:54,960 So Node node here. 40 00:02:54,960 --> 00:02:57,840 So we will make it heat. 41 00:02:58,320 --> 00:03:01,830 So as you can see here, heat is a node type. 42 00:03:03,340 --> 00:03:05,230 Function here, as you can see here. 43 00:03:05,410 --> 00:03:06,370 So. 44 00:03:07,320 --> 00:03:08,760 This is heat. 45 00:03:12,390 --> 00:03:12,940 You get? 46 00:03:14,860 --> 00:03:15,760 After that. 47 00:03:17,690 --> 00:03:19,840 Are we going to iterate with for loop? 48 00:03:19,850 --> 00:03:24,590 So we will iterate through the linked list elements until it finds the selected index here. 49 00:03:24,590 --> 00:03:34,460 So integer E here equals zero while the e is less than index, then increment E by one. 50 00:03:34,880 --> 00:03:40,070 After that we need to hear note and here after that. 51 00:03:40,100 --> 00:03:46,640 Next we will make note here and after the function here. 52 00:03:47,630 --> 00:03:50,480 We will return Node itself here. 53 00:03:50,600 --> 00:03:51,620 Return Node. 54 00:03:51,650 --> 00:03:52,550 So that's it. 55 00:03:52,550 --> 00:04:01,020 As you can see here, we developed all of the implementations here, so let's delete all of them here. 56 00:04:01,040 --> 00:04:07,340 So as you can see here, the complexity of the get operation is o here. 57 00:04:08,170 --> 00:04:11,860 Oh, and actually let me write the text. 58 00:04:11,860 --> 00:04:17,200 So the complexity of this operation is zero and N here. 59 00:04:17,500 --> 00:04:25,540 So since it has to iterate through the n elements here, so the elements is the this is the n elements 60 00:04:25,540 --> 00:04:26,620 in this case. 61 00:04:26,650 --> 00:04:27,700 Oops, not like this. 62 00:04:27,700 --> 00:04:30,550 So this is the n elements. 63 00:04:30,550 --> 00:04:33,610 The N is the number of elements which is here. 64 00:04:34,810 --> 00:04:36,010 N elements. 65 00:04:37,780 --> 00:04:41,520 And this you can find the element count here. 66 00:04:42,090 --> 00:04:43,230 The this is the worst case. 67 00:04:43,230 --> 00:04:47,510 If the element is at the last year at the end of the our node. 68 00:04:47,520 --> 00:04:49,170 So however. 69 00:04:50,430 --> 00:04:59,490 In the best case, the complexity can also be the zero here, zero one here. 70 00:05:00,180 --> 00:05:03,270 So the zero one in the list here. 71 00:05:03,270 --> 00:05:05,430 So no matter which index is selected. 72 00:05:05,940 --> 00:05:07,200 So if our. 73 00:05:07,990 --> 00:05:09,330 Node is the first here. 74 00:05:09,340 --> 00:05:12,370 So for example, one oops, not like this here. 75 00:05:12,370 --> 00:05:14,410 So if our list is like that here. 76 00:05:14,410 --> 00:05:17,970 So this is our first here. 77 00:05:17,980 --> 00:05:20,710 So this is our. 78 00:05:22,170 --> 00:05:24,900 The usual time complexity. 79 00:05:24,900 --> 00:05:27,740 And this is the best case scenario. 80 00:05:27,750 --> 00:05:30,360 In the worst case scenario, it's going to be here. 81 00:05:31,230 --> 00:05:34,200 In worst case scenario, it's going to be the last item. 82 00:05:34,200 --> 00:05:40,410 For example, if our node has three nine items, it will be the nine here. 83 00:05:40,410 --> 00:05:43,680 So this is our worst case scenario for the node here. 84 00:05:43,680 --> 00:05:47,850 However, in every node you will have different number of items.