title

Solving Programming Problems

description

Ge the Code Here: http://goo.gl/R6R1F
To finish off my Java Algorithm tutorial, I thought it would be interesting to cover solving programming problems in general. So, in this tutorial I'll answer the question I've been getting, which is how to print a tree data structure.
On our journey to better understand how to solve problems I will first solve the basic problem. Then in the next part of the tutorial I will perfect printing any type of tree. The code above will better explain the process of solving this problem.

detail

{'title': 'Solving Programming Problems', 'heatmap': [{'end': 292.399, 'start': 250.761, 'weight': 1}], 'summary': 'Covers solving custom programming problems, focusing on printing a tree structure using java algorithms and data structures, along with discussing tree structure modeling, iterators, loops, and tree printing, providing examples, algorithms, and code snippets for practical application.', 'chapters': [{'end': 70.565, 'segs': [{'end': 46.449, 'src': 'embed', 'start': 17.564, 'weight': 0, 'content': [{'end': 20.126, 'text': "This is going to be something that's custom, something that you need.", 'start': 17.564, 'duration': 2.562}, {'end': 27.393, 'text': "And I'm very specifically going to be answering a question in this tutorial that I've received many times over the past couple weeks.", 'start': 20.327, 'duration': 7.066}, {'end': 32.057, 'text': 'And that question was how to print a tree structure on a console.', 'start': 27.833, 'duration': 4.224}, {'end': 39.103, 'text': 'So, in essence, if we have an array and we want to print out a tree structure, like you see here, not with the lines and so forth,', 'start': 32.237, 'duration': 6.866}, {'end': 46.449, 'text': 'but just dashes and then a number and then dashes and another number and another number and so forth, and so on, How exactly do we do this??', 'start': 39.103, 'duration': 7.346}], 'summary': 'The tutorial will address how to print a tree structure on a console, a question received multiple times.', 'duration': 28.885, 'max_score': 17.564, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT017564.jpg'}, {'end': 76.862, 'src': 'embed', 'start': 52.293, 'weight': 1, 'content': [{'end': 58.217, 'text': "I'm going to go out of my way to try to approach this as a person that has a limited understanding of programming,", 'start': 52.293, 'duration': 5.924}, {'end': 66.242, 'text': 'so that we can teach a subject that I think is extremely important, which is to teach how to solve any problem,', 'start': 58.217, 'duration': 8.025}, {'end': 69.464, 'text': 'not just how to solve one specific problem.', 'start': 66.242, 'duration': 3.222}, {'end': 70.565, 'text': "So let's get into it.", 'start': 69.584, 'duration': 0.981}, {'end': 76.862, 'text': "Okay. so if we want to actually come in here and figure out how we're going to draw a tree on the screen,", 'start': 71.297, 'duration': 5.565}], 'summary': 'Teaching problem-solving in programming is crucial for understanding, not just specific problems.', 'duration': 24.569, 'max_score': 52.293, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT052293.jpg'}], 'start': 0.149, 'title': 'Solving custom programming problems', 'summary': 'Focuses on solving custom programming problems, specifically addressing how to print a tree structure on a console using java algorithms and data structures, emphasizing the importance of teaching problem-solving skills.', 'chapters': [{'end': 70.565, 'start': 0.149, 'title': 'Solving custom programming problems', 'summary': 'Focuses on solving custom programming problems, specifically addressing how to print a tree structure on a console using java algorithms and data structures, emphasizing the importance of teaching problem-solving skills.', 'duration': 70.416, 'highlights': ['The chapter emphasizes the importance of solving custom programming problems and teaches how to print a tree structure on a console. The tutorial focuses on solving custom programming problems and specifically addresses the task of printing a tree structure on a console using Java algorithms and data structures.', 'The tutorial aims to teach problem-solving skills by approaching the problem as a person with limited understanding of programming. The tutorial intentionally approaches the problem as if the presenter has limited programming knowledge to teach the important skill of problem-solving, not just solving one specific problem.']}], 'duration': 70.416, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT0149.jpg', 'highlights': ['The tutorial focuses on solving custom programming problems and specifically addresses printing a tree structure on a console using Java algorithms and data structures.', 'The chapter emphasizes the importance of teaching problem-solving skills by approaching the problem as a person with limited understanding of programming.']}, {'end': 633.543, 'segs': [{'end': 109.111, 'src': 'embed', 'start': 85.549, 'weight': 0, 'content': [{'end': 92.054, 'text': "So what we're going to do, just to keep everything simple here, is to figure out exactly how many indexes we're going to have.", 'start': 85.549, 'duration': 6.505}, {'end': 99.32, 'text': "So we know that a tree structure is going to have one at the top and then it's going to have two afterwards and then it's going to have four after that.", 'start': 92.374, 'duration': 6.946}, {'end': 100.801, 'text': "And then finally it's going to have 8.", 'start': 99.64, 'duration': 1.161}, {'end': 104.426, 'text': "So let's go out here and actually model that structure.", 'start': 100.801, 'duration': 3.625}, {'end': 106.688, 'text': "So I'm just going to act like we have one digit.", 'start': 104.646, 'duration': 2.042}, {'end': 109.111, 'text': "And I'm actually going to present this in a couple different ways.", 'start': 106.868, 'duration': 2.243}], 'summary': 'Analyzing tree structure with 1, 2, 4, and 8 indexes.', 'duration': 23.562, 'max_score': 85.549, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT085549.jpg'}, {'end': 292.399, 'src': 'heatmap', 'start': 250.761, 'weight': 1, 'content': [{'end': 254.724, 'text': "Let's come into Wolfram Alpha, and there it is, Wolfram Alpha right there.", 'start': 250.761, 'duration': 3.963}, {'end': 259.367, 'text': "And there we go, we just pumped in our numbers, 7, 3, 1, and 0, and we're going to hit equals.", 'start': 254.984, 'duration': 4.383}, {'end': 262.83, 'text': 'And this is going to provide us with our algorithm that we need to solve.', 'start': 259.688, 'duration': 3.142}, {'end': 267.135, 'text': 'All right, and we scroll down through here, and we can see that here it is.', 'start': 263.09, 'duration': 4.045}, {'end': 268.617, 'text': 'This is our answer.', 'start': 267.275, 'duration': 1.342}, {'end': 272.461, 'text': "This is the guy that's going to provide us with all the numbers we need for our indent.", 'start': 268.697, 'duration': 3.764}, {'end': 278.609, 'text': "And that's going to be negative 2 to the power of negative n, negative 16 plus 2 to the power of n.", 'start': 272.642, 'duration': 5.967}, {'end': 279.97, 'text': 'That is the guy we need.', 'start': 278.789, 'duration': 1.181}, {'end': 282.992, 'text': "So now let's jump back over and let's calculate that out.", 'start': 280.13, 'duration': 2.862}, {'end': 292.399, 'text': "So it's going to be negative 2 to the power of n multiplied times negative 16 plus 2 to the power of n.", 'start': 283.072, 'duration': 9.327}], 'summary': 'Using wolfram alpha to solve algorithm, resulting in -2^n * (-16 + 2^n)', 'duration': 41.638, 'max_score': 250.761, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT0250761.jpg'}, {'end': 299.965, 'src': 'embed', 'start': 268.697, 'weight': 1, 'content': [{'end': 272.461, 'text': "This is the guy that's going to provide us with all the numbers we need for our indent.", 'start': 268.697, 'duration': 3.764}, {'end': 278.609, 'text': "And that's going to be negative 2 to the power of negative n, negative 16 plus 2 to the power of n.", 'start': 272.642, 'duration': 5.967}, {'end': 279.97, 'text': 'That is the guy we need.', 'start': 278.789, 'duration': 1.181}, {'end': 282.992, 'text': "So now let's jump back over and let's calculate that out.", 'start': 280.13, 'duration': 2.862}, {'end': 292.399, 'text': "So it's going to be negative 2 to the power of n multiplied times negative 16 plus 2 to the power of n.", 'start': 283.072, 'duration': 9.327}, {'end': 299.965, 'text': 'And from looking at this, n in this situation is going to be represented by 1 as we are generating these indents.', 'start': 292.399, 'duration': 7.566}], 'summary': 'Calculation of negative 2 to the power of n for generating indents with n=1.', 'duration': 31.268, 'max_score': 268.697, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT0268697.jpg'}, {'end': 361.379, 'src': 'embed', 'start': 336.741, 'weight': 2, 'content': [{'end': 344.127, 'text': 'Well, the cool thing about generating trees is what was once the indent then becomes the space, and so forth and so on.', 'start': 336.741, 'duration': 7.386}, {'end': 349.591, 'text': "So that means for our spaces they're going to start off as 0,", 'start': 344.467, 'duration': 5.124}, {'end': 356.015, 'text': 'and then whatever indent was the previous time that we cycled through and generated this tree.', 'start': 349.591, 'duration': 6.424}, {'end': 358.557, 'text': 'So now we have three things that we know we have to create here.', 'start': 356.135, 'duration': 2.422}, {'end': 361.379, 'text': "So now let's go on here and start thinking about some of the other things.", 'start': 358.697, 'duration': 2.682}], 'summary': 'Generating trees involves adjusting spaces based on previous indents.', 'duration': 24.638, 'max_score': 336.741, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT0336741.jpg'}], 'start': 71.297, 'title': 'Tree structure modeling', 'summary': 'Discusses drawing a tree structure, modeling indentation and spaces, and generating indents and iterators. it covers examples, algorithms, and code snippets for tree structures.', 'chapters': [{'end': 120.039, 'start': 71.297, 'title': 'Drawing a tree structure', 'summary': 'Discusses the process of drawing a tree structure on the screen, using an example of a four-row tree and explaining the number of indexes needed for the structure.', 'duration': 48.742, 'highlights': ['The process involves determining the number of indexes needed for the tree structure, which follows a pattern of 1 at the top, 2 afterwards, 4 after that, and 8 finally.', 'The example focuses on modeling the structure of the tree with one digit and exploring different presentation methods to ensure functionality.']}, {'end': 292.399, 'start': 120.199, 'title': 'Modeling tree indentation and spaces', 'summary': 'Demonstrates the process of modeling a tree structure with varying indentation and spaces, with the algorithm for calculating the indentation provided as negative 2 to the power of negative n, negative 16 plus 2 to the power of n.', 'duration': 172.2, 'highlights': ['The algorithm for calculating the indentation is provided as negative 2 to the power of negative n, negative 16 plus 2 to the power of n, allowing for the determination of the necessary indent numbers.', 'The process of modeling a tree structure involves tracking the indentation and spaces for each row, with specific indent and space numbers determined for each row based on the structure.', 'Utilizing Wolfram Alpha, the numbers 7, 3, 1, and 0 are inputted to calculate the algorithm for determining the necessary indent numbers for modeling the tree structure.']}, {'end': 633.543, 'start': 292.399, 'title': 'Generating tree indents and iterators', 'summary': 'Discusses the calculation of indents, spaces, indexes, and items per row for generating tree structures using algorithms, with examples and code snippets provided.', 'duration': 341.144, 'highlights': ['The process involves calculating indents, spaces, indexes, and items per row for generating tree structures. The transcript provides insights into the calculation of indents, spaces, indexes, and items per row for generating tree structures using algorithms.', 'The calculation of indents and spaces involves iterative processes and is pivotal for generating the tree structures. The transcript emphasizes the iterative calculation of indents and spaces as pivotal for generating the tree structures.', 'The determination of indexes and items per row is demonstrated with examples and calculations using algorithms. The transcript demonstrates the determination of indexes and items per row through examples and calculations using algorithms.']}], 'duration': 562.246, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT071297.jpg', 'highlights': ['The process involves determining the number of indexes needed for the tree structure, following a pattern of 1 at the top, 2 afterwards, 4 after that, and 8 finally.', 'The algorithm for calculating the indentation is provided as negative 2 to the power of negative n, negative 16 plus 2 to the power of n, allowing for the determination of the necessary indent numbers.', 'The process involves calculating indents, spaces, indexes, and items per row for generating tree structures. The transcript provides insights into the calculation of indents, spaces, indexes, and items per row for generating tree structures using algorithms.']}, {'end': 974.475, 'segs': [{'end': 670.785, 'src': 'embed', 'start': 633.923, 'weight': 0, 'content': [{'end': 639.687, 'text': "Then I also know that I'm going to need an iterator and it's going to have to start out with the value of 1.", 'start': 633.923, 'duration': 5.764}, {'end': 640.547, 'text': 'And why do I know that??', 'start': 639.687, 'duration': 0.86}, {'end': 645.83, 'text': "Because I need an iterator that starts at 1 and that's going to be used in the place of n here,", 'start': 640.627, 'duration': 5.203}, {'end': 650.373, 'text': 'and then to calculate multiple other different things like here and so forth, and so on.', 'start': 645.83, 'duration': 4.543}, {'end': 651.554, 'text': "So there's my iterator.", 'start': 650.453, 'duration': 1.101}, {'end': 656.757, 'text': 'Then what do I need to do? Well I need to keep printing things out as long as I have rows.', 'start': 651.814, 'duration': 4.943}, {'end': 659.479, 'text': 'So that tells me that I need a while loop.', 'start': 657.077, 'duration': 2.402}, {'end': 662.681, 'text': 'See I used while in defining what I was trying to do.', 'start': 659.839, 'duration': 2.842}, {'end': 665.182, 'text': 'And this is iterator, not iteration.', 'start': 663.061, 'duration': 2.121}, {'end': 670.785, 'text': "And I'm going to continue printing stuff out on the screen as long as my iterator is less than my number of rows.", 'start': 665.202, 'duration': 5.583}], 'summary': 'The speaker discusses the need for an iterator starting at 1, to be used in a while loop for printing things as long as there are rows.', 'duration': 36.862, 'max_score': 633.923, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT0633923.jpg'}, {'end': 818.287, 'src': 'embed', 'start': 793.523, 'weight': 2, 'content': [{'end': 799.619, 'text': "the indent is j plus plus, and I'm just going to use this to print a whole bunch of spaces.", 'start': 793.523, 'duration': 6.096}, {'end': 802.4, 'text': 'Alright. Well, now that I have that in there,', 'start': 799.639, 'duration': 2.761}, {'end': 809.683, 'text': 'I also know that I have to print different numbers of numbers and spaces depending upon how many rows or how many different things I want to do.', 'start': 802.4, 'duration': 7.283}, {'end': 815.946, 'text': 'So how am I going to describe this? Well, I want to go from my index to print first.', 'start': 809.923, 'duration': 6.023}, {'end': 818.287, 'text': "That's going to be the first index per row.", 'start': 816.306, 'duration': 1.981}], 'summary': "Using 'j++' to print spaces and numbers based on rows and indexes.", 'duration': 24.764, 'max_score': 793.523, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT0793523.jpg'}, {'end': 943.326, 'src': 'embed', 'start': 912.955, 'weight': 4, 'content': [{'end': 917.337, 'text': "Okay, so now that we have all that set up, let's go and actually print this guy out.", 'start': 912.955, 'duration': 4.382}, {'end': 925.419, 'text': "So I'm going to go new heap dot, and we'll come in here and test out, print our tree, and we know that we have four rows inside of it.", 'start': 917.617, 'duration': 7.802}, {'end': 927.22, 'text': "Let's file save it, see what happens.", 'start': 925.579, 'duration': 1.641}, {'end': 934.322, 'text': "And there you can see is our tree, and it's all printed out nice and beautiful, exactly like we wanted.", 'start': 928.459, 'duration': 5.863}, {'end': 936.163, 'text': "Now there's only one problem with this.", 'start': 934.622, 'duration': 1.541}, {'end': 943.326, 'text': 'What happens if we change this to number of rows three, file save, and execute? Well, that prints out all nice and dandy.', 'start': 936.243, 'duration': 7.083}], 'summary': 'Successfully printed a tree with 4 rows, and tested printing with 3 rows.', 'duration': 30.371, 'max_score': 912.955, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT0912955.jpg'}, {'end': 972.875, 'src': 'embed', 'start': 950.709, 'weight': 3, 'content': [{'end': 959.972, 'text': 'So what would we do if we wanted to generate the ability to be able to print out both two-digit numbers and not be stuck with just one-digit number,', 'start': 950.709, 'duration': 9.263}, {'end': 966.973, 'text': 'but also we wanted to be able to print pretty much any type of tree we could possibly imagine?', 'start': 959.972, 'duration': 7.001}, {'end': 970.534, 'text': "Well, tune in to the next part of the video tutorial and you'll get your answer.", 'start': 967.173, 'duration': 3.361}, {'end': 972.875, 'text': 'Please leave any questions or comments below.', 'start': 971.134, 'duration': 1.741}], 'summary': 'Learn to print two-digit numbers and various types of trees in the next tutorial.', 'duration': 22.166, 'max_score': 950.709, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT0950709.jpg'}], 'start': 633.923, 'title': 'Iterators, loops, and tree printing', 'summary': 'Covers the use of an iterator and while loop for printing based on row numbers, as well as the process of coding a tree printing function. it includes details on indent calculation, for loop for printing spaces, and error handling.', 'chapters': [{'end': 670.785, 'start': 633.923, 'title': 'Iterator and while loop', 'summary': 'Discusses the use of an iterator starting at 1 and a while loop to continue printing as long as the iterator is less than the number of rows.', 'duration': 36.862, 'highlights': ['The need for an iterator starting at 1 is emphasized as it will be used in place of n and for calculating multiple other things.', 'The necessity of a while loop is highlighted to continue printing as long as the iterator is less than the number of rows.']}, {'end': 974.475, 'start': 671.126, 'title': 'Coding a tree printing function', 'summary': 'Explains the process of coding a tree printing function, including calculating indent, determining the first index to print and the number of items per row, creating a for loop to print spaces, and addressing potential errors in the code.', 'duration': 303.349, 'highlights': ['Explaining the process of calculating indent and the first index to print Calculation of indent and first index to print', 'Addressing potential errors in the code and the need for flexibility in printing different types of trees Handling potential errors and introducing flexibility in printing', 'Demonstrating the usage of the tree printing function with different inputs and highlighting potential issues Usage of tree printing function and identification of potential issues']}], 'duration': 340.552, 'thumbnail': 'https://coursnap.oss-ap-southeast-1.aliyuncs.com/video-capture/63BBWWsqsT0/pics/63BBWWsqsT0633923.jpg', 'highlights': ['The need for an iterator starting at 1 is emphasized for calculating multiple things.', 'The necessity of a while loop is highlighted to continue printing based on row numbers.', 'Explaining the process of calculating indent and the first index to print.', 'Addressing potential errors in the code and the need for flexibility in printing.', 'Demonstrating the usage of the tree printing function with different inputs and highlighting potential issues.']}], 'highlights': ['The tutorial focuses on solving custom programming problems and specifically addresses printing a tree structure on a console using Java algorithms and data structures.', 'The chapter emphasizes the importance of teaching problem-solving skills by approaching the problem as a person with limited understanding of programming.', 'The process involves calculating indents, spaces, indexes, and items per row for generating tree structures. The transcript provides insights into the calculation of indents, spaces, indexes, and items per row for generating tree structures using algorithms.', 'The algorithm for calculating the indentation is provided as negative 2 to the power of negative n, negative 16 plus 2 to the power of n, allowing for the determination of the necessary indent numbers.', 'The need for an iterator starting at 1 is emphasized for calculating multiple things.', 'The necessity of a while loop is highlighted to continue printing based on row numbers.', 'Explaining the process of calculating indent and the first index to print.', 'Addressing potential errors in the code and the need for flexibility in printing.', 'Demonstrating the usage of the tree printing function with different inputs and highlighting potential issues.', 'The process involves determining the number of indexes needed for the tree structure, following a pattern of 1 at the top, 2 afterwards, 4 after that, and 8 finally.']}