My Coding Place logo

The Source Code

A Blog on Learning Coding and STEM skills

A common term people use in computer science and coding is 'algorithm.' What is it and why is it important for coding? In partnership with Juni Learning, we share their article here to define this important concept.


What Is An Algorithm?

An algorithm is a set of step-by-step procedures, or a set of rules to follow, for completing a specific task or solving a particular problem. Algorithms are all around us. The recipe for baking a cake, the method we use to solve a long division problem, and the process of doing laundry are all examples of an algorithm. Here’s what baking a cake might look like, written out as a list of instructions, just like an algorithm:

  1. Preheat the oven

  2. Gather the ingredients

  3. Measure out the ingredients

  4. Mix together the ingredients to make the batter

  5. Grease a pan

  6. Pour the batter into the pan

  7. Put the pan in the oven

  8. Set a timer

  9. When the timer goes off, take the pan out of the oven

  10. Enjoy!

Algorithmic programming is all about writing a set of rules that instruct the computer how to perform a task. A computer program is essentially an algorithm that tells the computer what specific steps to execute, in what specific order, in order to carry out a specific task. Algorithms are written using particular syntax, depending on the programming language being used.

Types of Algorithms

Algorithms are classified based on the concepts that they use to accomplish a task. While there are many types of algorithms, the most fundamental types of computer science algorithms are:

  1. Divide and conquer algorithms – divide the problem into smaller subproblems of the same type; solve those smaller problems, and combine those solutions to solve the original problem.

  2. Brute force algorithms – try all possible solutions until a satisfactory solution is found.

  3. Randomized algorithms – use a random number at least once during the computation to find a solution to the problem.

  4. Greedy algorithms – find an optimal solution at the local level with the intent of finding an optimal solution for the whole problem.

  5. Recursive algorithms – solve the lowest and simplest version of a problem to then solve increasingly larger versions of the problem until the solution to the original problem is found.

  6. Backtracking algorithms – divide the problem into subproblems, each which can be attempted to be solved; however, if the desired solution is not reached, move backwards in the problem until a path is found that moves it forward.

  7. Dynamic programming algorithms – break a complex problem into a collection of simpler subproblems, then solve each of those subproblems only once, storing their solution for future use instead of re-computing their solutions.

Example of an Algorithm

Solving a Rubik’s Cube

There are a number of different algorithms, from simple to very complicated, that exist for solving a Rubik’s cube. Below is just one simple algorithm. First, let’s specify a notation to use (similar to picking a programming language).

Each of the six faces of a Rubik’s cube can be represented by the first letter of their name:

  • U - up

  • D - down

  • L - left

  • R - right

  • F - front

  • B - back

Each face can be turned in three different ways/directions. Using U as an example, these are represented as:

  • U - clockwise quarter-turn of the upper face

  • U' - counter-clockwise quarter-turn of the upper face

  • U2 - half turn in either direction of the upper face

Now, let’s go through the steps in the algorithm to solve a Rubik’s Cube. Feel free to grab one of your own and follow along!

Step 1: The Cross

  1. First, flip some edges so that there is a white cross on the upper face.

  2. Apply the following turns: F, R’, D’, R, F2, R’, U, R, U’, R’, R2, L2, U2, R2, L2.

  3. The cross is now solved.

Step 2: The White Corners

  1. The edges on the white face are now complete, but the corners remain.

  2. Depending on where the white-orange-green corner is in the puzzle, apply one of the following series of turns:

  3. Bottom: R’, D’, R, D (repeat until the corner moves to its correct place)

  4. Top: R’, D’, R, D (this moves the corner to the bottom; then, follow the above instructions)

Step 3: Middle Layer Edges

  1. Flip the cube so that the white is on the bottom.

  2. Look for an edge that is on the top face and doesn’t have yellow on it.

  3. Perform a U-turn so that the color on the front face of the edge matches with the center.

  4. Depending on the direction that the edge could go, apply one of the following series of turns:

  5. Left: U’, L’, U, L, U, F, U’, F’

  6. Right: U, R, U’, R’, U’, F’, U, F)

Step 4: Yellow Cross

  1. Apply the following turns, until a yellow cross on the face appears with the yellow center: F, R, U, R’, U’, F’.

  2. If there is an “L” shape, where the two yellow pieces showing are adjacent to each other, apply the following turns: F, U, R, U’, R’, F’.

  3. If there is a “Line” shape, which is horizontal, apply the following turns: F, R, U, R’, U’, F’.

Step 5: Sune and Antisune

  1. Look at the face with the yellow center.

  2. Depending on the below contingencies, apply one of the following series of turns:

  3. If there is only one oriented corner: R, U, R’, U, R, U2, R’ (repeat until the desired position is attained)

  4. There is one oriented corner and one right-facing corner: U2, R, U2, R’, U’, R, U’, R’

Step 6: Finishing the puzzle

  1. Look for sets of “headlights” (two stickers of the same color in the same row, separated by a sticker of a different color).

  2. Depending on how many there are, apply one of the following series of turns:

  3. If there are a set of headlights on each side: R, U’, R, U, R, U, R, U’, R’, U’, R2

  4. Otherwise: R’, F, R’, B2, R, F’, R’, B2, R2

Sorting Algorithms

A sorting algorithm is an algorithm that puts elements of a list in a certain order, usually in numerical or lexicographical order. Sorting is often an important first step in algorithms that solves more complex problems. There are a large number of sorting algorithms, each with their own benefits and costs. Below, we will focus on some of the more famous sorting algorithms.

  1. Linear sort: Find the smallest element in the list to be sorted, add it to a new list, and remove it from the original list. Repeat this until the original list is empty.

  2. Bubble sort: Compare the first two elements in the list, and if the first is greater than the second, swap them. Repeat this with every pair of adjacent elements in the list. Then, repeat this process until the list is fully sorted.

  3. Insertion sort: Compare each element in the list to all the prior elements until a smaller element is found. Swap these two elements. Repeat this process until the list is fully sorted.

Where are Algorithms Used in Computer Science?

Algorithms are used in every part of computer science. They form the field's backbone. In computer science, an algorithm gives the computer a specific set of instructions, which allows the computer to do everything, be it running a calculator or running a rocket. Computer programs are, at their core, algorithms written in programming languages that the computer can understand. Computer algorithms play a big role in how social media works: which posts show up, which ads are seen, and so on. These decisions are all made by algorithms. Google’s programmers use algorithms to optimize searches, predict what users are going to type, and more. In problem-solving, a big part of computer programming is knowing how to formulate an algorithm.


Why are Algorithms Important to Understand?

Algorithmic thinking, or the ability to define clear steps to solve a problem, is crucial in many different fields. Even if we’re not conscious of it, we use algorithms and algorithmic thinking all the time. Algorithmic thinking allows students to break down problems and conceptualize solutions in terms of discrete steps. Being able to understand and implement an algorithm requires students to practice structured thinking and reasoning abilities.


This article originally appeared on junilearning.com

Updated: Oct 27, 2020

Gaming is big business from e-sports to cloud gaming. Microsoft bought Mojang, makers of Minecraft, for 2.5 billion in 2014. This summer, Sony invested $250 million in Epic Games, creators of Fortnite. As Election Day approaches, the Biden Campaign recently launched new headquarters in the popular video game "Animal Crossing: New Horizon," where players can visit an island called Biden HQ and learn about his campaign. It doesn't get more exciting than video games, so who wouldn't want to develop them as a hobby or career?


Video games are developed using a variety of game engines and languages, such as C++, C#, GameMaker, Godot, Unity, and Unreal. Development may also involve graphics and design, using tools such as Blender and Illustrator. At My Coding Place, our Game Development track begins with Scratch followed by GameMaker, Unity, and Unreal. In our Digital Arts track, we introduce Photo Editing, Motion Graphics, and 3D Modeling.


While many of our instructors play video games as a hobby, our instructor who was a professional gamer departed earlier this year to continue his coaching career. As a result, we recently welcomed a seasoned game developer to our team, whose game credits include Tony Hawk, The Simpsons Game, and Terminator Dark Fate. Reasons to learn from our current Game Development instructor, include reasons to learn to code and learn digital art, combined with an interest and desire to contribute to the exciting world of video game development.


The Value of Coding


Knowing how to program is essential for developing games, and the skill will translate to many other disciplines even if video game development doesn't work out as a career. According to Juni Learning in their recent article 8 Reasons Coding For Kids Is Not A Fad, coding teaches computational thinking and is good for the brain. Coding teaches students how to do the following:

  • effectively break down problems into manageable parts

  • observe patterns in data

  • identify how these patterns are generated

  • develop the step-by-step instructions for solving those problems

This leads to better performance on cognitive tasks, "because coding activates areas of the brain that are associated with memory, attention, and logic," states the article.


Coding is great for children and adults because it stimulates critical thinking and helps improve performance on cognitive tasks. There are many resources for learning to code which we have examined in previous articles. Once basic skills are learned, building video games is a desirable outcome that many of our students express when we ask them what types of projects they are interested in coding.


Types of Coding For Video Games


While people can code games on their own, except for very simple mobile games, video game development requires a large team. On the creative side, game development companies need writers and artists. On the tech side, they need programmers, QA testers, and engineers. Video game development is a business, so companies also need marketers, accountants, and managers. Many people who aspire to become game developers, however, are interested in careers in programming. Skills in writing, character design, art, and animation are helpful too, and we will explore the artistic aspects in a future post.


Because modern video games include a lot of elements (online gameplay, 3D graphics, custom digital sound, custom game physics, AI, etc.), video game developers have to solve some pretty challenging computer science problems. They often specialize in specific areas of the software development process such as the following:

  • Gameplay programmers help develop a game's overall feel, and may work on audio and graphics

  • UI programmers build and maintain user interfaces

  • Game engine programmers work on both graphics and simulated physics

  • Physics engine programmers determine and program the simulated physics in games

  • Graphics engine programmers design and troubleshoot 3D graphic renderers for both 2D and 3D games

  • AI programmers design and develop the technology that allows NPCs in games to behave in a lifelike way

  • Network programmers write the code that lets players in different locations play together online

  • Audio programmers build sound engines for games

  • Input programmers develop the code that lets peripherals control gameplay

  • Porting programmers do what's necessary to make games created for one platform playable on other platforms

There are also video game programmers who specialize in creating games for specific platforms or creating certain types of games (e.g., action/adventure games or puzzles).


We listed the types of programming required for game development to illustrate the depth and breadth of skills used and aspects involved for developers in the field. To get started, a developer should lay the foundation for their game by selecting a genre and platform and documenting the design and features. Once they have an idea of what they want to build, learning to code will be the most time-intensive part.


We recommend starting with block coding languages like Scratch, then proceeding to game development platforms like GameMaker, Unity, and Unreal. In a future post, we will discuss the value of learning digital art to complement video game programming, among other applications of coding.


Summary


In summary, game development is just one area in which coding skills are paramount for success. Learning to code is not a fad and will benefit students in numerous ways, from nurturing critical thinking skills to improving memory and attention. Naturally, the desire to build video games appeals to many programmers as a relevant and engaging way to apply their skills. Furthermore, there are many aspects of programming to learn and apply in game development such as physics, audio, graphics, and AI programming. To that end, there are YouTube videos, college courses, websites, and books on coding and learning to build video games. If you need help, reach out to us at hello@mycodingplace.com!



Updated: Oct 7, 2020

We can't empower kids with problem-solving skills if we are the ones solving the problems. A few years ago, I watched in fascination as my toddler colored inside the lines after months of scribbling without control. One of the most rewarding parts of being a parent is witnessing the growth and development of children. How does this amazing process happen? How do kids learn and how does that inform the way we teach problem-solving?


STEM and STEAM education provides kids with tools for lifelong learning. The topics that we teach - digital arts, robotics, chess, and coding (DARCC) - all require critical thinking for success. Art and even writing require logical thinking to create something out of nothing. The ability to think independently is a necessary skill, and the understanding of how to nurture that is something that our team thinks about regularly and seeks to advance.


Ages and Stages


There is an age when students become capable of reasoning and logic. While all children are different, there is a general pattern. Jean Piaget, the first psychologist to make a systematic study of cognitive development, is known for his work on child development. We are most interested in his last two stages of development for teaching coding and problem-solving skills, the operational stages.

While children are still very concrete and literal in their thinking from ages 7-11, the last stage of Piaget's theory beginning at age 11 involves an increase in logic, the ability to use deductive reasoning, and an understanding of abstract ideas.[1]


The minimum ages for My Coding Place programs, which are 7 for beginners learning Scratch and chess and 9 for learning Python, were established using not only these developmental stages but also mechanical and engagement factors, with some languages requiring more typing and less graphics. Certainly our teens have displayed a stronger ability to think independently without requiring as much guidance as younger students. After we think about how students learn, we then want to consider how best to teach within that framework.


How To Teach Problem-Solving


Some studies show that high intelligence is nothing more than a great ability for pattern recognition and problem solving. We want to equip students with tools like coding, math, chess, etc that allow them to train their brain to solve problems. Our approach involves repetition and practice. We practice using loops and variables in almost every class, for example.


"New connections and pathways are fragile," says Swart a neuroscience lecturer at MIT, "and only through repetition and practice can those connections be established enough to become habitual or default behaviors."


In addition, we encourage two additional practices that help students succeed:


1) Plan And Evaluate


To teach kids to plan and evaluate, here is the general process and structure we follow:

  • define the problem

  • evaluate multiple solutions

  • identify the best solution

  • implement and get feedback

Students should have a plan to accomplish their goals, taking the time to think through approaches before starting to code or solving the problem.


2) Give Students Space


In order to make connections effectively, students need some internal struggle and conflict. Parents and teachers too readily step in to provide answers because it is awkward to see students struggling, and we want to help. It is also easier to give students answers then to lead them to an answer. We understand that students need building blocks, so it's a balance. They can't independently sew a pillow if they aren't taught how to thread a needle.


If we are always stepping in to make sure they get the right answer, when will they take the responsibility and when will they make mistakes so they can learn? If we are always there with the answer, what are they learning other than to depend on adults? We can't empower kids with problem-solving skills if we are the ones solving the problems.


Summary


How do kids learn? According to experts, children's capacity to think independently involves 4 stages of development. We can help support STEM learners before and when they are capable of more abstract thought and are developmentally ready to apply strategy and planning to their learning.


How do we teach? To teach problem-solving and coding, we use repetition and practice. In addition, we teach students to plan and evaluate, and we give students space by not being so quick to give them the right answer. We call this the Get Out Of The Way technique, appropriate and so important!


Understanding learning and exploring teaching techniques helps us empower students with the lifelong skill of problem-solving. We hope that the tools we equip them with will help them be successful in the years to come!



[1] Sobel AA, Resick PA, Rabalais AE. The effect of cognitive processing therapy on cognitions: impact statement coding. J Trauma Stress. 2009;22(3):205-11. doi:  10.1002/jts.20408