title
Multidimensional Arrays in C++ (2D arrays)

description
Patreon ► https://patreon.com/thecherno Twitter ► https://twitter.com/thecherno Instagram ► https://instagram.com/thecherno Discord ► https://thecherno.com/discord Series Playlist ► https://thecherno.com/cpp Thank you to the following Patreon supporters: - Dominic Pace - Kevin Gregory Agwaze - Sébastien Bervoets - Tobias Humig - Peter Siegmund - Kerem Demirer Gear I use: ----------------- BEST laptop for programming! ► http://geni.us/pakTES My FAVOURITE keyboard for programming! ► http://geni.us/zNhB FAVOURITE monitors for programming! ► http://geni.us/Ig6KBq MAIN Camera ► http://geni.us/t6xyDRO MAIN Lens ► http://geni.us/xGoDWT Second Camera ► http://geni.us/CYUQ Microphone ► http://geni.us/wqO6g7K

detail
{'title': 'Multidimensional Arrays in C++ (2D arrays)', 'heatmap': [{'end': 342.454, 'start': 328.746, 'weight': 0.93}, {'end': 448.666, 'start': 423.607, 'weight': 0.909}, {'end': 784.757, 'start': 765.154, 'weight': 0.92}, {'end': 1076.034, 'start': 1036.509, 'weight': 0.888}], 'summary': 'Covers the concept of multidimensional arrays in c++, including 2d, 3d, and 4d arrays, emphasizes the importance of pointers when dealing with arrays and memory management, discusses strategies for dealing with arrays using pointers, explains the allocation of 2d and 3d arrays, demonstrates the process of allocating and initializing 3d arrays using pointers in c, and explores challenges of memory fragmentation with multidimensional arrays.', 'chapters': [{'end': 71.56, 'segs': [{'end': 32.806, 'src': 'embed', 'start': 0.089, 'weight': 0, 'content': [{'end': 3.45, 'text': "Hey, what's up guys? My name is Echern and welcome back to my C++ series.", 'start': 0.089, 'duration': 3.361}, {'end': 7.472, 'text': "So today we're going to be talking all about multidimensional arrays in C++.", 'start': 3.89, 'duration': 3.582}, {'end': 11.793, 'text': "2D arrays, 3D arrays, 4D arrays doesn't matter how many dimensions we have.", 'start': 8.092, 'duration': 3.701}, {'end': 16.015, 'text': "I'm just calling them multidimensional arrays, because you can have as many dimensions as you want.", 'start': 11.793, 'duration': 4.222}, {'end': 20.577, 'text': "First of all, if you haven't seen my video on arrays, definitely check that out,", 'start': 16.715, 'duration': 3.862}, {'end': 23.198, 'text': "because I don't want to waste time here explaining what an array actually is.", 'start': 20.577, 'duration': 2.621}, {'end': 25.999, 'text': "We're just specifically going to focus on multidimensional arrays.", 'start': 23.258, 'duration': 2.741}, {'end': 29.803, 'text': "and also definitely check out my video on pointers, if you haven't already.", 'start': 26.619, 'duration': 3.184}, {'end': 32.806, 'text': "pointers are really important when you're dealing with arrays of any kind,", 'start': 29.803, 'duration': 3.003}], 'summary': 'Echern discusses multidimensional arrays in c++, emphasizing their flexibility and the importance of understanding pointers.', 'duration': 32.717, 'max_score': 0.089, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U89.jpg'}, {'end': 79.286, 'src': 'embed', 'start': 49.51, 'weight': 2, 'content': [{'end': 55.496, 'text': "So, multi-dimensional arrays we'll start with a 2D array, two-dimensional array, as an example.", 'start': 49.51, 'duration': 5.986}, {'end': 59.14, 'text': 'Really all it is, is just an array of arrays.', 'start': 56.177, 'duration': 2.963}, {'end': 68.197, 'text': "And then if you have a 3D array, it's an array of array of arrays, right? So a two-dimensional array is an array of arrays.", 'start': 60.171, 'duration': 8.026}, {'end': 71.56, 'text': "What I mean by that is it's literally a collection of arrays.", 'start': 68.237, 'duration': 3.323}, {'end': 79.286, 'text': 'So if we think about one of our kind of strategies for dealing with arrays is essentially by using a pointer.', 'start': 72.16, 'duration': 7.126}], 'summary': 'Introduction to multi-dimensional arrays, including 2d and 3d arrays, illustrating them as arrays of arrays.', 'duration': 29.776, 'max_score': 49.51, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U49510.jpg'}], 'start': 0.089, 'title': 'C++ multidimensional arrays', 'summary': 'Covers the concept of multidimensional arrays in c++, including 2d, 3d, and 4d arrays, and emphasizes the importance of pointers when dealing with arrays and memory management.', 'chapters': [{'end': 71.56, 'start': 0.089, 'title': 'C++ multidimensional arrays', 'summary': 'Covers the concept of multidimensional arrays in c++, including 2d, 3d, and 4d arrays, and emphasizes the importance of pointers when dealing with arrays and memory management.', 'duration': 71.471, 'highlights': ['Multidimensional arrays in C++ can have any number of dimensions. The chapter emphasizes that multidimensional arrays in C++ can have any number of dimensions, highlighting the flexibility of this concept.', 'Understanding pointers is crucial when dealing with arrays in C++. The importance of pointers when dealing with arrays in C++ is emphasized, underscoring their crucial role in memory management and manipulation.', '2D arrays are essentially an array of arrays. The concept of 2D arrays is explained as an array of arrays, providing a clear understanding of their structure.']}], 'duration': 71.471, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U89.jpg', 'highlights': ['Multidimensional arrays in C++ can have any number of dimensions.', 'Understanding pointers is crucial when dealing with arrays in C++.', '2D arrays are essentially an array of arrays.']}, {'end': 367.666, 'segs': [{'end': 114.897, 'src': 'embed', 'start': 72.16, 'weight': 2, 'content': [{'end': 79.286, 'text': 'So if we think about one of our kind of strategies for dealing with arrays is essentially by using a pointer.', 'start': 72.16, 'duration': 7.126}, {'end': 83.81, 'text': 'So we have a pointer to the beginning of the array as it appears in our memory.', 'start': 79.326, 'duration': 4.484}, {'end': 85.311, 'text': "That's how we kind of.", 'start': 84.23, 'duration': 1.081}, {'end': 89.59, 'text': "That's how we deal with an array in this case, right?", 'start': 86.567, 'duration': 3.023}, {'end': 95.135, 'text': 'So if you picture that and then you picture an array of those pointers,', 'start': 90.17, 'duration': 4.965}, {'end': 105.085, 'text': 'what you kind of end up with is I have a buffer in my memory which contains consecutive kind of pointers,', 'start': 95.135, 'duration': 9.95}, {'end': 109.29, 'text': 'and each one of those pointers points to a array somewhere in my memory.', 'start': 105.085, 'duration': 4.205}, {'end': 114.897, 'text': 'So what you end up with is a collection of pointers to arrays, an array of arrays, right?', 'start': 109.971, 'duration': 4.926}], 'summary': 'Using pointers to create a collection of arrays.', 'duration': 42.737, 'max_score': 72.16, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U72160.jpg'}, {'end': 174.382, 'src': 'embed', 'start': 132.885, 'weight': 1, 'content': [{'end': 136.446, 'text': "I'm just using heap allocation for now, because it's going to be easier to explain,", 'start': 132.885, 'duration': 3.561}, {'end': 139.587, 'text': "because we get a pointer straight away and it's just a bit more apparent what this actually is.", 'start': 136.446, 'duration': 3.141}, {'end': 145.388, 'text': "If I want to have a two dimensional array, what I'm going to do is have a pointer of pointers,", 'start': 140.147, 'duration': 5.241}, {'end': 152.45, 'text': "because what I'm actually storing here is going to be a buffer of pointer objects, right?", 'start': 145.388, 'duration': 7.062}, {'end': 156.013, 'text': 'So this is a pointer to a collection of int pointers.', 'start': 152.47, 'duration': 3.543}, {'end': 164.317, 'text': 'This is where it gets a little bit tricky because the allocation of two dimensional arrays in C++ is not really that straightforward.', 'start': 156.913, 'duration': 7.404}, {'end': 166.999, 'text': 'In other languages like C, sharp or Java.', 'start': 164.798, 'duration': 2.201}, {'end': 168.18, 'text': 'you can just kind of.', 'start': 166.999, 'duration': 1.181}, {'end': 173.382, 'text': "It will allocate all the memory that it needs to for you, and it's really easy to deal with.", 'start': 169, 'duration': 4.382}, {'end': 174.382, 'text': "With C++, it's not.", 'start': 173.402, 'duration': 0.98}], 'summary': 'Explaining heap allocation and challenges with two-dimensional arrays in c++.', 'duration': 41.497, 'max_score': 132.885, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U132885.jpg'}, {'end': 228.199, 'src': 'embed', 'start': 203.322, 'weight': 3, 'content': [{'end': 209.647, 'text': 'But if we had an actual class or a struct or something that was 20 bytes large, for example,', 'start': 203.322, 'duration': 6.325}, {'end': 215.091, 'text': "then in the first case what we're actually doing is we're allocating 50 20-byte chunks right?", 'start': 209.647, 'duration': 5.444}, {'end': 219.315, 'text': 'Which essentially ends up with us having 1, 000 bytes of allocated memory.', 'start': 215.712, 'duration': 3.603}, {'end': 224.937, 'text': "Whereas here, what we're doing is we're allocating 50 pointers.", 'start': 219.955, 'duration': 4.982}, {'end': 228.199, 'text': "So 50 times four, so it's 200 bytes of memory.", 'start': 225.678, 'duration': 2.521}], 'summary': 'Allocating 50 20-byte chunks equals 1000 bytes, while 50 pointers equals 200 bytes.', 'duration': 24.877, 'max_score': 203.322, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U203322.jpg'}, {'end': 363.343, 'src': 'heatmap', 'start': 328.746, 'weight': 0, 'content': [{'end': 330.486, 'text': "that's a different operation, right?", 'start': 328.746, 'duration': 1.74}, {'end': 334.648, 'text': "Because if I address it like this, I'm talking about an integer.", 'start': 330.827, 'duration': 3.821}, {'end': 339.892, 'text': "Whereas if I address it like this, I'm talking about an integer pointer because that's the underlying type.", 'start': 335.028, 'duration': 4.864}, {'end': 342.454, 'text': "So that's kind of step one to this whole process.", 'start': 340.513, 'duration': 1.941}, {'end': 345.057, 'text': "And that's kind of my way of teaching C++.", 'start': 342.494, 'duration': 2.563}, {'end': 348.18, 'text': "I need you to realize what's actually happening behind the scenes,", 'start': 345.137, 'duration': 3.043}, {'end': 352.644, 'text': "because that's the only way you're going to get good at using this language is by knowing what's happening,", 'start': 348.18, 'duration': 4.464}, {'end': 354.826, 'text': 'so that you can then kind of play around with that and change that.', 'start': 352.644, 'duration': 2.182}, {'end': 363.343, 'text': 'So the big thing here is again, the type is just setting basically the syntax that you can use to deal with this data.', 'start': 355.779, 'duration': 7.564}], 'summary': 'Teaching c++ by understanding underlying operations and types.', 'duration': 34.597, 'max_score': 328.746, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U328746.jpg'}], 'start': 72.16, 'title': 'Dealing with arrays using pointers and c++ 2d array allocation', 'summary': 'Discusses strategies for dealing with arrays using pointers, including creating a collection of pointers to arrays and an array of arrays. it also explains the allocation of 2d arrays in c++, emphasizing the difference in memory allocation and the fact that allocation only reserves memory without initializing data.', 'chapters': [{'end': 114.897, 'start': 72.16, 'title': 'Dealing with arrays using pointers', 'summary': 'Discusses strategies for dealing with arrays using pointers, explaining how a collection of pointers to arrays, an array of arrays, can be created in memory.', 'duration': 42.737, 'highlights': ['Explaining the strategy of using a pointer to deal with arrays and how it appears in memory.', 'Describing the creation of a collection of pointers to arrays, forming an array of arrays in memory.']}, {'end': 367.666, 'start': 115.358, 'title': 'C++ 2d array allocation', 'summary': 'Explains the allocation of 2d arrays in c++, highlighting the difference in memory allocation between using a pointer to an integer and a pointer to a pointer to an integer, and emphasizing that the allocation only reserves memory and does not initialize data.', 'duration': 252.308, 'highlights': ['The difference in memory allocation between using a pointer to an integer and a pointer to a pointer to an integer is explained, with the former allocating 1,000 bytes for 50 20-byte chunks and the latter allocating 200 bytes for 50 pointers.', 'Emphasizes that the allocation of 2D arrays in C++ only reserves memory and does not initialize data, allowing flexibility in data type usage within the allocated memory space.', 'The importance of understanding the underlying memory allocation process in C++ to effectively utilize the language and manipulate data is highlighted, encouraging learners to comprehend the mechanics behind the syntax.', 'The chapter provides a practical demonstration of heap allocation for a simple array and illustrates the use of a pointer of pointers to create a 2D array structure in C++, enhancing comprehension through code examples.']}], 'duration': 295.506, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U72160.jpg', 'highlights': ['The importance of understanding the underlying memory allocation process in C++ to effectively utilize the language and manipulate data is highlighted, encouraging learners to comprehend the mechanics behind the syntax.', 'The chapter provides a practical demonstration of heap allocation for a simple array and illustrates the use of a pointer of pointers to create a 2D array structure in C++, enhancing comprehension through code examples.', 'Describing the creation of a collection of pointers to arrays, forming an array of arrays in memory.', 'The difference in memory allocation between using a pointer to an integer and a pointer to a pointer to an integer is explained, with the former allocating 1,000 bytes for 50 20-byte chunks and the latter allocating 200 bytes for 50 pointers.', 'Explaining the strategy of using a pointer to deal with arrays and how it appears in memory.', 'Emphasizes that the allocation of 2D arrays in C++ only reserves memory and does not initialize data, allowing flexibility in data type usage within the allocated memory space.']}, {'end': 555.784, 'segs': [{'end': 394.647, 'src': 'embed', 'start': 368.166, 'weight': 0, 'content': [{'end': 376.57, 'text': 'So what we want to achieve with our two-dimensional array kind of system here is now that we have room to store 200 bytes worth of pointers,', 'start': 368.166, 'duration': 8.404}, {'end': 377.171, 'text': 'so 50 pointers.', 'start': 376.57, 'duration': 0.601}, {'end': 385.598, 'text': 'we can then go through and set each of those pointers to point to an array.', 'start': 379.412, 'duration': 6.186}, {'end': 394.647, 'text': 'And that way what we actually end up with is 50 arrays, right? So we have an array of arrays.', 'start': 386.659, 'duration': 7.988}], 'summary': 'Storing 50 arrays with 200 bytes worth of pointers.', 'duration': 26.481, 'max_score': 368.166, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U368166.jpg'}, {'end': 459.075, 'src': 'embed', 'start': 423.607, 'weight': 2, 'content': [{'end': 427.431, 'text': "What we've done here is we've essentially allocated 50 arrays.", 'start': 423.607, 'duration': 3.824}, {'end': 434.436, 'text': 'And each one of those arrays, the location of each one of those arrays is stored inside this A2D array.', 'start': 428.752, 'duration': 5.684}, {'end': 437.238, 'text': 'And that is what a two-dimensional array is.', 'start': 435.097, 'duration': 2.141}, {'end': 440.28, 'text': "Now, if you had a three-dimensional array, you'd have a nested for loop.", 'start': 437.778, 'duration': 2.502}, {'end': 448.666, 'text': "So you'd go through and you'd allocate, you'd have to allocate essentially, you know, the inner level, which is kind of one dimension.", 'start': 440.701, 'duration': 7.965}, {'end': 459.075, 'text': 'Again, it might be easier to just picture like Cube or something or a great kind of cube grid right and then just kind of go through and picture filling up each cell,', 'start': 448.706, 'duration': 10.369}], 'summary': 'Allocated 50 arrays stored in a 2d array, explained 3d array with nested for loop', 'duration': 35.468, 'max_score': 423.607, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U423607.jpg'}, {'end': 459.075, 'src': 'heatmap', 'start': 423.607, 'weight': 0.909, 'content': [{'end': 427.431, 'text': "What we've done here is we've essentially allocated 50 arrays.", 'start': 423.607, 'duration': 3.824}, {'end': 434.436, 'text': 'And each one of those arrays, the location of each one of those arrays is stored inside this A2D array.', 'start': 428.752, 'duration': 5.684}, {'end': 437.238, 'text': 'And that is what a two-dimensional array is.', 'start': 435.097, 'duration': 2.141}, {'end': 440.28, 'text': "Now, if you had a three-dimensional array, you'd have a nested for loop.", 'start': 437.778, 'duration': 2.502}, {'end': 448.666, 'text': "So you'd go through and you'd allocate, you'd have to allocate essentially, you know, the inner level, which is kind of one dimension.", 'start': 440.701, 'duration': 7.965}, {'end': 459.075, 'text': 'Again, it might be easier to just picture like Cube or something or a great kind of cube grid right and then just kind of go through and picture filling up each cell,', 'start': 448.706, 'duration': 10.369}], 'summary': 'Allocated 50 arrays stored in a 2d array, explaining two-dimensional and three-dimensional arrays with nested for loop.', 'duration': 35.468, 'max_score': 423.607, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U423607.jpg'}, {'end': 491.886, 'src': 'embed', 'start': 462.277, 'weight': 1, 'content': [{'end': 464.86, 'text': "There'd be three dimensions to that, It'd be the same.", 'start': 462.277, 'duration': 2.583}, {'end': 467.282, 'text': 'here might actually just be easier for me to show you so.', 'start': 464.86, 'duration': 2.422}, {'end': 471.711, 'text': "a three-dimensional array would look like this and we'd have a triple pointer here.", 'start': 467.282, 'duration': 4.429}, {'end': 473.933, 'text': "We'd be allocating a pointer of pointers.", 'start': 472.111, 'duration': 1.822}, {'end': 481.198, 'text': 'Then what we would do here is we know that we have 50 pointers to pointers, okay? So this is getting a bit more confusing.', 'start': 474.493, 'duration': 6.705}, {'end': 485.661, 'text': "So what we have to do here is actually say and I'll call this a3d,", 'start': 481.618, 'duration': 4.043}, {'end': 491.886, 'text': "we'd have to say a3d at index i and I'll actually change these to be probably x and y.", 'start': 485.661, 'duration': 6.225}], 'summary': 'Explanation of allocating a three-dimensional array with 50 pointers to pointers.', 'duration': 29.609, 'max_score': 462.277, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U462277.jpg'}], 'start': 368.166, 'title': 'Array implementation and allocation', 'summary': 'Explains implementing a two-dimensional array system to store 50 arrays of 50 integers using 200 bytes of pointers, and the process of allocating three-dimensional arrays, creating multiple indices for a multidimensional grid.', 'chapters': [{'end': 440.28, 'start': 368.166, 'title': 'Two-dimensional array implementation', 'summary': 'Explains the implementation of a two-dimensional array system that can store 50 arrays, each of 50 integers, resulting in a total of 2500 integers, by using 200 bytes worth of pointers.', 'duration': 72.114, 'highlights': ['The system allows the storage of 50 arrays, each with 50 integers, resulting in a total of 2500 integers, using 200 bytes worth of pointers.', 'The process involves allocating 50 arrays and storing the memory locations of each array inside the two-dimensional array.', 'The implementation includes a loop through 50 times to create and store 50 arrays in the two-dimensional array.']}, {'end': 555.784, 'start': 440.701, 'title': 'Allocating three-dimensional arrays', 'summary': 'Explains the process of allocating three-dimensional arrays, involving the allocation of pointers to pointers and the creation of multiple indices for a multidimensional grid.', 'duration': 115.083, 'highlights': ['The process involves allocating a pointer of pointers for a three-dimensional array, with 50 pointers to pointers, and then allocating new pointers for each of these, resulting in a multi-dimensional grid.', 'Explanation of dereferencing and referencing pointers in a three-dimensional array, illustrating the process with code examples and breaking down the steps to create a clearer understanding.']}], 'duration': 187.618, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U368166.jpg', 'highlights': ['The system allows the storage of 50 arrays, each with 50 integers, using 200 bytes worth of pointers.', 'The process involves allocating a pointer of pointers for a three-dimensional array, with 50 pointers to pointers, and then allocating new pointers for each of these.', 'The process involves allocating 50 arrays and storing the memory locations of each array inside the two-dimensional array.', 'Explanation of dereferencing and referencing pointers in a three-dimensional array, illustrating the process with code examples.']}, {'end': 781.477, 'segs': [{'end': 654.989, 'src': 'embed', 'start': 597.817, 'weight': 0, 'content': [{'end': 601.66, 'text': 'I might actually make a video on what pointers to pointers mean because that might be confusing in itself.', 'start': 597.817, 'duration': 3.843}, {'end': 604.901, 'text': "But anyway, we've allocated 50 pointers to pointers right?", 'start': 602.08, 'duration': 2.821}, {'end': 615.975, 'text': "We're going through each of those pointers to pointers and creating an array of pointers, And then we're going through each of those pointers,", 'start': 605.762, 'duration': 10.213}, {'end': 618.316, 'text': 'because what we have here is just normal array of pointers.', 'start': 615.975, 'duration': 2.341}, {'end': 621.998, 'text': "And we're setting each of those pointers to an actual array.", 'start': 618.916, 'duration': 3.082}, {'end': 624.839, 'text': "So we're allocating our actual type here, int.", 'start': 622.238, 'duration': 2.601}, {'end': 630.382, 'text': 'And this is what we would, this is the actual type allocation, because this is, you can note, this is just a pointer allocation.', 'start': 625.26, 'duration': 5.122}, {'end': 634.685, 'text': "Like we're allocating an array of pointers here, but here we're actually allocating our array of integers.", 'start': 630.422, 'duration': 4.263}, {'end': 643.106, 'text': "And then if we want to access this, we'd have to go A3D and then kind of, you know, the outer coordinate, the middle coordinate.", 'start': 635.245, 'duration': 7.861}, {'end': 645.327, 'text': "So X, Y, and then we'll say Z.", 'start': 643.306, 'duration': 2.021}, {'end': 647.427, 'text': "And then that's how we would set each one of those.", 'start': 645.327, 'duration': 2.1}, {'end': 650.548, 'text': 'Okay, so you can see that it literally is a three-dimensional array.', 'start': 647.707, 'duration': 2.841}, {'end': 654.989, 'text': "Because if we just take that, that's going to give us an array of pointer to pointers.", 'start': 651.048, 'duration': 3.941}], 'summary': 'Allocated 50 pointers to pointers to create a three-dimensional array of integers.', 'duration': 57.172, 'max_score': 597.817, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U597817.jpg'}, {'end': 721.297, 'src': 'embed', 'start': 696.934, 'weight': 1, 'content': [{'end': 703.44, 'text': "that's what this column is, whereas this column on the right here is actually this inner array that you're dealing with.", 'start': 696.934, 'duration': 6.506}, {'end': 707.539, 'text': "okay, so that's two-dimensional arrays.", 'start': 703.44, 'duration': 4.099}, {'end': 712.145, 'text': 'Now when it comes to deleting them, which is what we have to do as well.', 'start': 707.679, 'duration': 4.466}, {'end': 721.297, 'text': 'if we heap allocate them like this, you have to go through and iterate and delete all of those arrays, because you cannot just delete this.', 'start': 712.145, 'duration': 9.152}], 'summary': 'The discussion covers 2d arrays and the need to iterate for deletion.', 'duration': 24.363, 'max_score': 696.934, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U696934.jpg'}, {'end': 781.477, 'src': 'embed', 'start': 757.007, 'weight': 3, 'content': [{'end': 764.554, 'text': "We can't delete them in the future because we just deleted the array that held those pointers that told us where those other arrays were.", 'start': 757.007, 'duration': 7.547}, {'end': 772.455, 'text': 'So what you actually have to do to delete this is iterate through this 50 times and delete A2D at index i like that.', 'start': 765.154, 'duration': 7.301}, {'end': 773.615, 'text': 'That is what deletes it.', 'start': 772.695, 'duration': 0.92}, {'end': 776.496, 'text': 'And then finally, you also have to delete A2D.', 'start': 773.635, 'duration': 2.861}, {'end': 779.216, 'text': "So that's kind of the reverse of that.", 'start': 776.896, 'duration': 2.32}, {'end': 781.477, 'text': 'All right.', 'start': 781.037, 'duration': 0.44}], 'summary': 'To delete, iterate 50 times, delete a2d at index i, and then delete a2d.', 'duration': 24.47, 'max_score': 757.007, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U757007.jpg'}], 'start': 555.784, 'title': '3d arrays and array deletion in c/c++', 'summary': 'Discusses the complex process of allocating and initializing 3d arrays using pointers in c, involving the allocation of 50 pointers and arrays of pointers, leading to the allocation of arrays of integers. additionally, it explains the concept of 3d arrays in c, demonstrating how to access elements and highlighting the difference between pointer arrays and integers. furthermore, it covers the process of deleting two-dimensional arrays in c++, emphasizing the need to iterate through the arrays and delete them individually to avoid memory leaks, highlighting the necessity of deleting a2d at index i and a2d as the final steps.', 'chapters': [{'end': 634.685, 'start': 555.784, 'title': '3d pointer allocation and array initialization', 'summary': 'Discusses the complex process of allocating a 3d array using pointers and initializing arrays, involving the allocation of 50 pointers and arrays of pointers, leading to the allocation of arrays of integers.', 'duration': 78.901, 'highlights': ['The process involves allocating 50 pointers and then creating arrays of pointers, followed by setting each pointer to an actual array, resulting in the allocation of arrays of integers.', 'The type allocation involves both pointer and actual array allocations, with the process being complex and requiring careful understanding.', 'The topic may be confusing and may require visual aids or additional resources for better comprehension.']}, {'end': 696.934, 'start': 635.245, 'title': 'Understanding 3d arrays in c', 'summary': 'Explains the concept of 3d arrays in c, demonstrating how to access elements and highlighting the difference between pointer arrays and integers.', 'duration': 61.689, 'highlights': ['The array is accessed using three coordinates: X, Y, and Z, making it a three-dimensional array.', 'Explained the concept of array of pointers and how it differs from an array of integers.', 'Clarified the method to access elements in a 2D array, emphasizing the difference between accessing integer and pointer arrays.']}, {'end': 781.477, 'start': 696.934, 'title': 'Deleting two-dimensional arrays in c++', 'summary': 'Discusses deleting two-dimensional arrays in c++, emphasizing the need to iterate through the arrays and delete them individually to avoid memory leaks, highlighting the necessity of deleting a2d at index i and a2d as the final steps.', 'duration': 84.543, 'highlights': ['Iterating through the 2D arrays and deleting them individually is crucial to prevent memory leaks, as deleting the array that holds pointers to the integer arrays will result in inaccessible memory, constituting a memory leak.', 'Deleting A2D at index i is necessary to properly delete the individual arrays within the 2D array and avoid potential memory leaks.', 'The final step involves deleting A2D to complete the process of deleting the two-dimensional array in C++.']}], 'duration': 225.693, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U555784.jpg', 'highlights': ['The process involves allocating 50 pointers and then creating arrays of pointers, followed by setting each pointer to an actual array, resulting in the allocation of arrays of integers.', 'Iterating through the 2D arrays and deleting them individually is crucial to prevent memory leaks, as deleting the array that holds pointers to the integer arrays will result in inaccessible memory, constituting a memory leak.', 'The array is accessed using three coordinates: X, Y, and Z, making it a three-dimensional array.', 'Deleting A2D at index i is necessary to properly delete the individual arrays within the 2D array and avoid potential memory leaks.', 'Explained the concept of array of pointers and how it differs from an array of integers.']}, {'end': 1203.206, 'segs': [{'end': 944.026, 'src': 'embed', 'start': 910.862, 'weight': 0, 'content': [{'end': 918.449, 'text': 'a lot slower to iterate through these 25 integers this way than if I had just allocated a single dimensional array.', 'start': 910.862, 'duration': 7.587}, {'end': 923.052, 'text': 'of 25 integers in a row in memory, because that memory is going to be all in a row.', 'start': 919.21, 'duration': 3.842}, {'end': 924.833, 'text': 'And one of the most important things.', 'start': 923.672, 'duration': 1.161}, {'end': 928.055, 'text': "when you're programming and you're optimizing and you're dealing with memory well,", 'start': 924.833, 'duration': 3.222}, {'end': 931.897, 'text': 'one of the most important things you can do to optimize is actually optimize your memory accessing.', 'start': 928.055, 'duration': 3.842}, {'end': 942.525, 'text': "So if you can store memory close together that you'll be accessing and you can kind of actually position it in a way that results in more cache hits and less cache misses,", 'start': 932.317, 'duration': 10.208}, {'end': 944.026, 'text': 'your program will perform faster.', 'start': 942.525, 'duration': 1.501}], 'summary': 'Iterating through 25 integers is slower than using a single dimensional array, optimizing memory access can result in faster program performance.', 'duration': 33.164, 'max_score': 910.862, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U910862.jpg'}, {'end': 1076.034, 'src': 'heatmap', 'start': 1036.509, 'weight': 0.888, 'content': [{'end': 1038.611, 'text': 'Easy, right? But you could also write it this way.', 'start': 1036.509, 'duration': 2.102}, {'end': 1049.453, 'text': "And then it's just, instead of doing that, you just say X plus Y times the width of your array, which is five.", 'start': 1040.191, 'duration': 9.262}, {'end': 1054.254, 'text': "So this kind of dimension over here, right? Or this dimension here doesn't really matter.", 'start': 1049.953, 'duration': 4.301}, {'end': 1056.955, 'text': "Well, it doesn't matter because it's your width.", 'start': 1054.274, 'duration': 2.681}, {'end': 1062.716, 'text': "If you have a grid, this is your width, because what you're saying here is you're saying that every time the Y increments,", 'start': 1056.995, 'duration': 5.721}, {'end': 1068.318, 'text': 'I want you to jump five elements forward, which would be the equivalent of just dropping down a row if you had your grid.', 'start': 1062.716, 'duration': 5.602}, {'end': 1076.034, 'text': "Okay We can talk about this in more detail if you would like, leave a comment below and I'll see what kind of, what your thoughts are.", 'start': 1068.818, 'duration': 7.216}], 'summary': 'Explanation of a computational concept using x plus y times the width of the array, with a specific example of width five.', 'duration': 39.525, 'max_score': 1036.509, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U1036509.jpg'}, {'end': 1153.567, 'src': 'embed', 'start': 1114.909, 'weight': 3, 'content': [{'end': 1119.293, 'text': 'has to jump to a completely different array in memory, whereas this is just accessing that same memory.', 'start': 1114.909, 'duration': 4.384}, {'end': 1121.435, 'text': "that's all in a row in our actual memory.", 'start': 1119.293, 'duration': 2.142}, {'end': 1125.199, 'text': 'So I personally avoid 2D arrays as much as possible.', 'start': 1122.216, 'duration': 2.983}, {'end': 1127.261, 'text': 'Sometimes it makes a lot of sense to use them.', 'start': 1125.539, 'duration': 1.722}, {'end': 1128.502, 'text': "Most of the time it doesn't.", 'start': 1127.601, 'duration': 0.901}, {'end': 1136.069, 'text': 'Okay, If I was storing a bitmap, for example, and I had all the pixels in an image,', 'start': 1128.522, 'duration': 7.547}, {'end': 1141.033, 'text': 'you might think of an image like a photo or like a texture as a 2D thing, right?', 'start': 1136.069, 'duration': 4.964}, {'end': 1143.896, 'text': "Like, you've got pixels and it's like it is like a 2D grid, right?", 'start': 1141.073, 'duration': 2.823}, {'end': 1145.618, 'text': 'So I should store it as a 2D array, right?', 'start': 1144.176, 'duration': 1.442}, {'end': 1146.62, 'text': 'No.', 'start': 1146.4, 'duration': 0.22}, {'end': 1148.582, 'text': 'Store it as a single-dimensional array.', 'start': 1147.041, 'duration': 1.541}, {'end': 1153.567, 'text': "It doesn't matter that you can't, like, you can still, it doesn't matter how you store it.", 'start': 1148.962, 'duration': 4.605}], 'summary': 'Avoid 2d arrays, use single-dimensional array for images.', 'duration': 38.658, 'max_score': 1114.909, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U1114909.jpg'}], 'start': 781.917, 'title': 'Array storage and memory fragmentation', 'summary': 'Explores challenges of memory fragmentation with multidimensional arrays, emphasizing the impact on performance due to cache misses and the benefits of optimizing memory access. it also discusses the inefficiency of 2d arrays and demonstrates the performance benefits of using single-dimensional arrays for efficient data storage.', 'chapters': [{'end': 944.026, 'start': 781.917, 'title': 'Multidimensional arrays and memory fragmentation', 'summary': 'Explains the challenges of dealing with memory fragmentation when using multidimensional arrays, highlighting the impact on performance due to cache misses and the benefits of optimizing memory access for faster program performance.', 'duration': 162.109, 'highlights': ['Memory fragmentation is a significant issue when dealing with an array of arrays, leading to potential cache misses and slower program performance.', 'Storing memory close together can result in more cache hits and less cache misses, optimizing memory access for faster program performance.', 'Using a single dimensional array of 25 integers in a row in memory is faster than iterating through 25 integers in a multidimensional array due to memory being all in a row, resulting in quicker access and improved program performance.']}, {'end': 1203.206, 'start': 944.446, 'title': 'Efficient array storage', 'summary': 'Discusses the inefficiency of 2d arrays and demonstrates a more efficient way of storing data using single-dimensional arrays, with an emphasis on the performance benefits of the latter over the former.', 'duration': 258.76, 'highlights': ['Storing 25 integers in a single-dimensional array is more efficient than using a 2D array due to faster memory access Using a single-dimensional array to store 25 integers is more efficient than a 2D array, as it allows for faster memory access.', 'Performance benefits of single-dimensional arrays over 2D arrays demonstrated through accessing memory The performance benefits of single-dimensional arrays over 2D arrays are demonstrated through faster memory access, as the former accesses the same memory in a row, while the latter requires jumping to a different array in memory.', 'Recommendation to store images as single-dimensional arrays for optimal storage For optimal storage, it is recommended to store images as single-dimensional arrays, as it proves to be a much more efficient way of storing images compared to using 2D arrays.']}], 'duration': 421.289, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/gNgUMA_Ur0U/pics/gNgUMA_Ur0U781917.jpg', 'highlights': ['Storing memory close together can result in more cache hits and less cache misses, optimizing memory access for faster program performance.', 'Using a single dimensional array of 25 integers in a row in memory is faster than iterating through 25 integers in a multidimensional array due to memory being all in a row, resulting in quicker access and improved program performance.', 'Storing 25 integers in a single-dimensional array is more efficient than using a 2D array due to faster memory access.', 'Performance benefits of single-dimensional arrays over 2D arrays demonstrated through accessing memory.', 'Recommendation to store images as single-dimensional arrays for optimal storage.']}], 'highlights': ['Understanding pointers is crucial when dealing with arrays in C++.', 'The importance of understanding the underlying memory allocation process in C++ to effectively utilize the language and manipulate data is highlighted, encouraging learners to comprehend the mechanics behind the syntax.', 'The process involves allocating 50 pointers and then creating arrays of pointers, followed by setting each pointer to an actual array, resulting in the allocation of arrays of integers.', 'The system allows the storage of 50 arrays, each with 50 integers, using 200 bytes worth of pointers.', 'Storing memory close together can result in more cache hits and less cache misses, optimizing memory access for faster program performance.']}