- 1. Micro-Worlds
- 2. Light-Bot in Java
- 3. Jeroos of Santong Island
- 4. Problem Solving and Algorithms
- 5. Creating Jeroo Methods
- 6. Conditionally Executing Actions
- 7. Repeating Actions
- 8. Handling Touch Events
- 9. Adding Text to the Screen
Problem Solving and Algorithms
Learn a basic process for developing a solution to a problem. Nothing in this chapter is unique to using a computer to solve a problem. This process can be used to solve a wide variety of problems, including ones that have nothing to do with computers.
Problems, Solutions, and Tools
I have a problem! I need to thank Aunt Kay for the birthday present she sent me. I could send a thank you note through the mail. I could call her on the telephone. I could send her an email message. I could drive to her house and thank her in person. In fact, there are many ways I could thank her, but that's not the point. The point is that I must decide how I want to solve the problem, and use the appropriate tool to implement (carry out) my plan. The postal service, the telephone, the internet, and my automobile are tools that I can use, but none of these actually solves my problem. In a similar way, a computer does not solve problems, it's just a tool that I can use to implement my plan for solving the problem.
Knowing that Aunt Kay appreciates creative and unusual things, I have decided to hire a singing messenger to deliver my thanks. In this context, the messenger is a tool, but one that needs instructions from me. I have to tell the messenger where Aunt Kay lives, what time I would like the message to be delivered, and what lyrics I want sung. A computer program is similar to my instructions to the messenger.
The story of Aunt Kay uses a familiar context to set the stage for a useful point of view concerning computers and computer programs. The following list summarizes the key aspects of this point of view.
A computer is a tool that can be used to implement a plan for solving a problem.
A computer program is a set of instructions for a computer. These instructions describe the steps that the computer must follow to implement a plan.
An algorithm is a plan for solving a problem.
A person must design an algorithm.
A person must translate an algorithm into a computer program.
This point of view sets the stage for a process that we will use to develop solutions to Jeroo problems. The basic process is important because it can be used to solve a wide variety of problems, including ones where the solution will be written in some other programming language.
An Algorithm Development Process
Every problem solution starts with a plan. That plan is called an algorithm.
There are many ways to write an algorithm. Some are very informal, some are quite formal and mathematical in nature, and some are quite graphical. The instructions for connecting a DVD player to a television are an algorithm. A mathematical formula such as πR 2 is a special case of an algorithm. The form is not particularly important as long as it provides a good way to describe and check the logic of the plan.
The development of an algorithm (a plan) is a key step in solving a problem. Once we have an algorithm, we can translate it into a computer program in some programming language. Our algorithm development process consists of five major steps.
Step 1: Obtain a description of the problem.
Step 2: analyze the problem., step 3: develop a high-level algorithm., step 4: refine the algorithm by adding more detail., step 5: review the algorithm..
This step is much more difficult than it appears. In the following discussion, the word client refers to someone who wants to find a solution to a problem, and the word developer refers to someone who finds a way to solve the problem. The developer must create an algorithm that will solve the client's problem.
The client is responsible for creating a description of the problem, but this is often the weakest part of the process. It's quite common for a problem description to suffer from one or more of the following types of defects: (1) the description relies on unstated assumptions, (2) the description is ambiguous, (3) the description is incomplete, or (4) the description has internal contradictions. These defects are seldom due to carelessness by the client. Instead, they are due to the fact that natural languages (English, French, Korean, etc.) are rather imprecise. Part of the developer's responsibility is to identify defects in the description of a problem, and to work with the client to remedy those defects.
The purpose of this step is to determine both the starting and ending points for solving the problem. This process is analogous to a mathematician determining what is given and what must be proven. A good problem description makes it easier to perform this step.
When determining the starting point, we should start by seeking answers to the following questions:
What data are available?
Where is that data?
What formulas pertain to the problem?
What rules exist for working with the data?
What relationships exist among the data values?
When determining the ending point, we need to describe the characteristics of a solution. In other words, how will we know when we're done? Asking the following questions often helps to determine the ending point.
What new facts will we have?
What items will have changed?
What changes will have been made to those items?
What things will no longer exist?
An algorithm is a plan for solving a problem, but plans come in several levels of detail. It's usually better to start with a high-level algorithm that includes the major part of a solution, but leaves the details until later. We can use an everyday example to demonstrate a high-level algorithm.
Problem: I need a send a birthday card to my brother, Mark.
Analysis: I don't have a card. I prefer to buy a card rather than make one myself.
Go to a store that sells greeting cards Select a card Purchase a card Mail the card
This algorithm is satisfactory for daily use, but it lacks details that would have to be added were a computer to carry out the solution. These details include answers to questions such as the following.
"Which store will I visit?"
"How will I get there: walk, drive, ride my bicycle, take the bus?"
"What kind of card does Mark like: humorous, sentimental, risqué?"
These kinds of details are considered in the next step of our process.
A high-level algorithm shows the major steps that need to be followed to solve a problem. Now we need to add details to these steps, but how much detail should we add? Unfortunately, the answer to this question depends on the situation. We have to consider who (or what) is going to implement the algorithm and how much that person (or thing) already knows how to do. If someone is going to purchase Mark's birthday card on my behalf, my instructions have to be adapted to whether or not that person is familiar with the stores in the community and how well the purchaser known my brother's taste in greeting cards.
When our goal is to develop algorithms that will lead to computer programs, we need to consider the capabilities of the computer and provide enough detail so that someone else could use our algorithm to write a computer program that follows the steps in our algorithm. As with the birthday card problem, we need to adjust the level of detail to match the ability of the programmer. When in doubt, or when you are learning, it is better to have too much detail than to have too little.
Most of our examples will move from a high-level to a detailed algorithm in a single step, but this is not always reasonable. For larger, more complex problems, it is common to go through this process several times, developing intermediate level algorithms as we go. Each time, we add more detail to the previous algorithm, stopping when we see no benefit to further refinement. This technique of gradually working from a high-level to a detailed algorithm is often called stepwise refinement .
The final step is to review the algorithm. What are we looking for? First, we need to work through the algorithm step by step to determine whether or not it will solve the original problem. Once we are satisfied that the algorithm does provide a solution to the problem, we start to look for other things. The following questions are typical of ones that should be asked whenever we review an algorithm. Asking these questions and seeking their answers is a good way to develop skills that can be applied to the next problem.
Does this algorithm solve a very specific problem or does it solve a more general problem ? If it solves a very specific problem, should it be generalized?
For example, an algorithm that computes the area of a circle having radius 5.2 meters (formula π*5.2 2 ) solves a very specific problem, but an algorithm that computes the area of any circle (formula π*R 2 ) solves a more general problem.
Can this algorithm be simplified ?
One formula for computing the perimeter of a rectangle is:
length + width + length + width
A simpler formula would be:
2.0 * ( length + width )
Is this solution similar to the solution to another problem? How are they alike? How are they different?
For example, consider the following two formulae:
Rectangle area = length * width Triangle area = 0.5 * base * height
Similarities: Each computes an area. Each multiplies two measurements.
Differences: Different measurements are used. The triangle formula contains 0.5.
Hypothesis: Perhaps every area formula involves multiplying two measurements.
Example 4.1: Pick and Plant
This section contains an extended example that demonstrates the algorithm development process. To complete the algorithm, we need to know that every Jeroo can hop forward, turn left and right, pick a flower from its current location, and plant a flower at its current location.
Problem Statement (Step 1)
A Jeroo starts at (0, 0) facing East with no flowers in its pouch. There is a flower at location (3, 0). Write a program that directs the Jeroo to pick the flower and plant it at location (3, 2). After planting the flower, the Jeroo should hop one space East and stop. There are no other nets, flowers, or Jeroos on the island.
Analysis of the Problem (Step 2)
The flower is exactly three spaces ahead of the jeroo.
The flower is to be planted exactly two spaces South of its current location.
The Jeroo is to finish facing East one space East of the planted flower.
There are no nets to worry about.
High-level Algorithm (Step 3)
Let's name the Jeroo Bobby. Bobby should do the following:
Get the flower Put the flower Hop East
Detailed Algorithm (Step 4)
Get the flower Hop 3 times Pick the flower Put the flower Turn right Hop 2 times Plant a flower Hop East Turn left Hop once
Review the Algorithm (Step 5)
The high-level algorithm partitioned the problem into three rather easy subproblems. This seems like a good technique.
This algorithm solves a very specific problem because the Jeroo and the flower are in very specific locations.
This algorithm is actually a solution to a slightly more general problem in which the Jeroo starts anywhere, and the flower is 3 spaces directly ahead of the Jeroo.
Java Code for "Pick and Plant"
A good programmer doesn't write a program all at once. Instead, the programmer will write and test the program in a series of builds. Each build adds to the previous one. The high-level algorithm will guide us in this process.
To see this solution in action, create a new Greenfoot4Sofia scenario and use the Edit Palettes Jeroo menu command to make the Jeroo classes visible. Right-click on the Island class and create a new subclass with the name of your choice. This subclass will hold your new code.
The recommended first build contains three things:
The main method (here myProgram() in your island subclass).
Declaration and instantiation of every Jeroo that will be used.
The high-level algorithm in the form of comments.
The instantiation at the beginning of myProgram() places bobby at (0, 0), facing East, with no flowers.
Once the first build is working correctly, we can proceed to the others. In this case, each build will correspond to one step in the high-level algorithm. It may seem like a lot of work to use four builds for such a simple program, but doing so helps establish habits that will become invaluable as the programs become more complex.
This build adds the logic to "get the flower", which in the detailed algorithm (step 4 above) consists of hopping 3 times and then picking the flower. The new code is indicated by comments that wouldn't appear in the original (they are just here to call attention to the additions). The blank lines help show the organization of the logic.
By taking a moment to run the work so far, you can confirm whether or not this step in the planned algorithm works as expected.
This build adds the logic to "put the flower". New code is indicated by the comments that are provided here to mark the additions.
FOURTH BUILD (final)
Example 4.2: replace net with flower.
This section contains a second example that demonstrates the algorithm development process.
There are two Jeroos. One Jeroo starts at (0, 0) facing North with one flower in its pouch. The second starts at (0, 2) facing East with one flower in its pouch. There is a net at location (3, 2). Write a program that directs the first Jeroo to give its flower to the second one. After receiving the flower, the second Jeroo must disable the net, and plant a flower in its place. After planting the flower, the Jeroo must turn and face South. There are no other nets, flowers, or Jeroos on the island.
Jeroo_2 is exactly two spaces behind Jeroo_1.
The only net is exactly three spaces ahead of Jeroo_2.
Each Jeroo has exactly one flower.
Jeroo_2 will have two flowers after receiving one from Jeroo_1. One flower must be used to disable the net. The other flower must be planted at the location of the net, i.e. (3, 2).
Jeroo_1 will finish at (0, 1) facing South.
Jeroo_2 is to finish at (3, 2) facing South.
Each Jeroo will finish with 0 flowers in its pouch. One flower was used to disable the net, and the other was planted.
Let's name the first Jeroo Ann and the second one Andy.
Ann should do the following: Find Andy (but don't collide with him) Give a flower to Andy (he will be straight ahead) After receiving the flower, Andy should do the following: Find the net (but don't hop onto it) Disable the net Plant a flower at the location of the net Face South
Ann should do the following: Find Andy Turn around (either left or right twice) Hop (to location (0, 1)) Give a flower to Andy Give ahead Now Andy should do the following: Find the net Hop twice (to location (2, 2)) Disable the net Toss Plant a flower at the location of the net Hop (to location (3, 2)) Plant a flower Face South Turn right
The high-level algorithm helps manage the details.
This algorithm solves a very specific problem, but the specific locations are not important. The only thing that is important is the starting location of the Jeroos relative to one another and the location of the net relative to the second Jeroo's location and direction.
Java Code for "Replace Net with Flower"
As before, the code should be written incrementally as a series of builds. Four builds will be suitable for this problem. As usual, the first build will contain the main method, the declaration and instantiation of the Jeroo objects, and the high-level algorithm in the form of comments. The second build will have Ann give her flower to Andy. The third build will have Andy locate and disable the net. In the final build, Andy will place the flower and turn East.
This build creates the main method, instantiates the Jeroos, and outlines the high-level algorithm. In this example, the main method would be myProgram() contained within a subclass of Island .
This build adds the logic for Ann to locate Andy and give him a flower.
This build adds the logic for Andy to locate and disable the net.
This build adds the logic for Andy to place a flower at (3, 2) and turn South.
Smart. Open. Grounded. Inventive. Read our Ideas Made to Matter.
Which program is right for you?
Through intellectual rigor and experiential learning, this full-time, two-year MBA program develops leaders who make a difference in the world.
A rigorous, hands-on program that prepares adaptive problem solvers for premier finance careers.
A 12-month program focused on applying the tools of modern data science, optimization and machine learning to solve real-world business problems.
Earn your MBA and SM in engineering with this transformative two-year program.
Combine an international MBA with a deep dive into management science. A special opportunity for partner and affiliate schools only.
A doctoral program that produces outstanding scholars who are leading in their fields of research.
Bring a business perspective to your technical and quantitative expertise with a bachelor’s degree in management, business analytics, or finance.
A joint program for mid-career professionals that integrates engineering and systems thinking. Earn your master’s degree in engineering and management.
An interdisciplinary program that combines engineering, management, and design, leading to a master’s degree in engineering and management.
A full-time MBA program for mid-career leaders eager to dedicate one year of discovery for a lifetime of impact.
This 20-month MBA program equips experienced executives to enhance their impact on their organizations and the world.
Non-degree programs for senior executives and high-potential managers.
A non-degree, customizable program for mid-career professionals.
Why this Labor Day Is different
SEC chair Gary Gensler’s 2020 paper details 5 concerns about AI and finance
Why B2B platforms struggle to succeed
Credit: Alejandro Giraldo
Ideas Made to Matter
How to use algorithms to solve everyday problems
May 8, 2017
How can I navigate the grocery store quickly? Why doesn’t anyone like my Facebook status? How can I alphabetize my bookshelves in a hurry? Apple data visualizer and MIT System Design and Management graduate Ali Almossawi solves these common dilemmas and more in his new book, “ Bad Choices: How Algorithms Can Help You Think Smarter and Live Happier ,” a quirky, illustrated guide to algorithmic thinking.
For the uninitiated: What is an algorithm? And how can algorithms help us to think smarter?
An algorithm is a process with unambiguous steps that has a beginning and an end, and does something useful.
Algorithmic thinking is taking a step back and asking, “If it’s the case that algorithms are so useful in computing to achieve predictability, might they also be useful in everyday life, when it comes to, say, deciding between alternative ways of solving a problem or completing a task?” In all cases, we optimize for efficiency: We care about time or space.
Note the mention of “deciding between.” Computer scientists do that all the time, and I was convinced that the tools they use to evaluate competing algorithms would be of interest to a broad audience.
Why did you write this book, and who can benefit from it?
All the books I came across that tried to introduce computer science involved coding. My approach to making algorithms compelling was focusing on comparisons. I take algorithms and put them in a scene from everyday life, such as matching socks from a pile, putting books on a shelf, remembering things, driving from one point to another, or cutting an onion. These activities can be mapped to one or more fundamental algorithms, which form the basis for the field of computing and have far-reaching applications and uses.
I wrote the book with two audiences in mind. One, anyone, be it a learner or an educator, who is interested in computer science and wants an engaging and lighthearted, but not a dumbed-down, introduction to the field. Two, anyone who is already familiar with the field and wants to experience a way of explaining some of the fundamental concepts in computer science differently than how they’re taught.
I’m going to the grocery store and only have 15 minutes. What do I do?
Do you know what the grocery store looks like ahead of time? If you know what it looks like, it determines your list. How do you prioritize things on your list? Order the items in a way that allows you to avoid walking down the same aisles twice.
For me, the intriguing thing is that the grocery store is a scene from everyday life that I can use as a launch pad to talk about various related topics, like priority queues and graphs and hashing. For instance, what is the most efficient way for a machine to store a prioritized list, and what happens when the equivalent of you scratching an item from a list happens in the machine’s list? How is a store analogous to a graph (an abstraction in computer science and mathematics that defines how things are connected), and how is navigating the aisles in a store analogous to traversing a graph?
Nobody follows me on Instagram. How do I get more followers?
The concept of links and networks, which I cover in Chapter 6, is relevant here. It’s much easier to get to people whom you might be interested in and who might be interested in you if you can start within the ball of links that connects those people, rather than starting at a random spot.
You mention Instagram: There, the hashtag is one way to enter that ball of links. Tag your photos, engage with users who tag their photos with the same hashtags, and you should be on your way to stardom.
What are the secret ingredients of a successful Facebook post?
I’ve posted things on social media that have died a sad death and then posted the same thing at a later date that somehow did great. Again, if we think of it in terms that are relevant to algorithms, we’d say that the challenge with making something go viral is really getting that first spark. And to get that first spark, a person who is connected to the largest number of people who are likely to engage with that post, needs to share it.
With [my first book], “Bad Arguments,” I spent a month pouring close to $5,000 into advertising for that project with moderate results. And then one science journalist with a large audience wrote about it, and the project took off and hasn’t stopped since.
What problems do you wish you could solve via algorithm but can’t?
When we care about efficiency, thinking in terms of algorithms is useful. There are cases when that’s not the quality we want to optimize for — for instance, learning or love. I walk for several miles every day, all throughout the city, as I find it relaxing. I’ve never asked myself, “What’s the most efficient way I can traverse the streets of San Francisco?” It’s not relevant to my objective.
Algorithms are a great way of thinking about efficiency, but the question has to be, “What approach can you optimize for that objective?” That’s what worries me about self-help: Books give you a silver bullet for doing everything “right” but leave out all the nuances that make us different. What works for you might not work for me.
Which companies use algorithms well?
When you read that the overwhelming majority of the shows that users of, say, Netflix, watch are due to Netflix’s recommendation engine, you know they’re doing something right.
If you're seeing this message, it means we're having trouble loading external resources on our website.
If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.
Unit 1: Algorithms
About this unit, intro to algorithms.
- What is an algorithm and why should you care? (Opens a modal)
- A guessing game (Opens a modal)
- Route-finding (Opens a modal)
- Discuss: Algorithms in your life (Opens a modal)
- Binary search (Opens a modal)
- Implementing binary search of an array (Opens a modal)
- Challenge: Binary search (Opens a modal)
- Running time of binary search (Opens a modal)
- Running time of binary search 5 questions Practice
- Asymptotic notation (Opens a modal)
- Big-θ (Big-Theta) notation (Opens a modal)
- Functions in asymptotic notation (Opens a modal)
- Big-O notation (Opens a modal)
- Big-Ω (Big-Omega) notation (Opens a modal)
- Comparing function growth 4 questions Practice
- Asymptotic notation 5 questions Practice
- Sorting (Opens a modal)
- Challenge: implement swap (Opens a modal)
- Selection sort pseudocode (Opens a modal)
- Challenge: Find minimum in subarray (Opens a modal)
- Challenge: implement selection sort (Opens a modal)
- Analysis of selection sort (Opens a modal)
- Project: Selection sort visualizer (Opens a modal)
- Insertion sort (Opens a modal)
- Challenge: implement insert (Opens a modal)
- Insertion sort pseudocode (Opens a modal)
- Challenge: Implement insertion sort (Opens a modal)
- Analysis of insertion sort (Opens a modal)
- Recursion (Opens a modal)
- The factorial function (Opens a modal)
- Challenge: Iterative factorial (Opens a modal)
- Recursive factorial (Opens a modal)
- Challenge: Recursive factorial (Opens a modal)
- Properties of recursive algorithms (Opens a modal)
- Using recursion to determine whether a word is a palindrome (Opens a modal)
- Challenge: is a string a palindrome? (Opens a modal)
- Computing powers of a number (Opens a modal)
- Challenge: Recursive powers (Opens a modal)
- Multiple recursion with the Sierpinski gasket (Opens a modal)
- Improving efficiency of recursive functions (Opens a modal)
- Project: Recursive art (Opens a modal)
Towers of Hanoi
- Towers of Hanoi (Opens a modal)
- Towers of Hanoi, continued (Opens a modal)
- Challenge: Solve Hanoi recursively (Opens a modal)
- Move three disks in Towers of Hanoi 3 questions Practice
- Divide and conquer algorithms (Opens a modal)
- Overview of merge sort (Opens a modal)
- Challenge: Implement merge sort (Opens a modal)
- Linear-time merging (Opens a modal)
- Challenge: Implement merge (Opens a modal)
- Analysis of merge sort (Opens a modal)
- Overview of quicksort (Opens a modal)
- Challenge: Implement quicksort (Opens a modal)
- Linear-time partitioning (Opens a modal)
- Challenge: Implement partition (Opens a modal)
- Analysis of quicksort (Opens a modal)
- Describing graphs (Opens a modal)
- Representing graphs (Opens a modal)
- Challenge: Store a graph (Opens a modal)
- Describing graphs 6 questions Practice
- Representing graphs 5 questions Practice
- Breadth-first search and its uses (Opens a modal)
- The breadth-first search algorithm (Opens a modal)
- Challenge: Implement breadth-first search (Opens a modal)
- Analysis of breadth-first search (Opens a modal)
- Where to go from here (Opens a modal)
Posted on Nov 18, 2021
Algorithmic Problem Solving - Step by Step
Let's be real - in the current job market most employers want to know that you can not only learn a coding language, but also apply it while actively problem solving. In walks algorithm problems (or also fondly know as algos ) which are often used as a tool for employers to filter for exactly what they're looking for. At first glance, algorithm problems can be intimidating! The secret to tackling these is going step by step.
Steps to algorithmic problem solving
Google often has a lot to tell us. One of the many things is how to go about solving a problem. There are four recommended steps: analyze, implement, experiment, design. Lets go through these four steps and talk through what exactly is being recommended.
Read through the problem presented. What is the problem being presented? Are there any specifications being listed/stated? If it's easier to separate the problem into sections, do that! Try stating the problem in your own words to solidify that you understand the problem.
We have a firm grasp of the problem at hand. Now, how would we go about solving this problem? What steps do we need to take to solve the problem? Write line by line (similar to how you would write out your code) what exactly you need to do to get the desired outcome.
This is the fun part - write out your own test cases for the code you'll eventually write. Include what you expect the return to be as well. Think through what you have written out so far, is there a test that would break your code? Include that too. Coding can be fun - embrace the unknown.
Our own algorithmic problem to solve
Here's our problem:
Confirm whether or not a word is a palindrome.
Analyze The current problem is asking for a function that will confirm whether or not a string is the same both backwards and forwards. The example it gave is true or false which also implies that this will involve comparing the string at some point in my code. For our use, let's assume that it will only give single word strings and that case doesn't matter or all strings are lowercase.
Implement Based on the problem's expected answer I'll probably attempt to solve the algorithm like so:
- Create a function that takes a string as an argument
- Compare the initial string to the same string that is reversed using an if statement
Experiment Let's make test cases with expected results! For now, I'll only list the test cases, but think through what you think will work. There's a couple palindromes that are actually two words instead of one, something that isn't accounted for in the hard code. Let's find out what the code does.
Design After rereading the problem and how it could be solved this is what should work:
Here's our results:
That's an algorithm problem from start to finish. Though intimidating, they are definitely possible to tackle. Remember - analyze, implement, experiment, and design make breaking down the problem into bite size pieces easier.
Top comments (0)
Templates let you quickly answer FAQs or store snippets for re-use.
Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink .
Hide child comments as well
For further actions, you may consider blocking this person and/or reporting abuse
React Custom Hook: useScript
Sergey Leschev - Aug 26
Syed Muhammad Ali Raza - Aug 26
Comparing Ktor and Micronaut: Kotlin-Powered Application Servers 🔥💻
Sergio Marcial - Aug 26
Mastering React Component Development: Best Practices for Maintenance, Testing, and Reusability
Ghazi Khan - Aug 13
Once suspended, katelynjewel will not be able to comment or publish posts until their suspension is removed.
Once unsuspended, katelynjewel will be able to comment and publish posts again.
Once unpublished, all posts by katelynjewel will become hidden and only accessible to themselves.
If katelynjewel is not suspended, they can still re-publish their posts from their dashboard.
Once unpublished, this post will become invisible to the public and only accessible to Katelyn.
They can still re-publish the post if they are not suspended.
Thanks for keeping DEV Community safe. Here is what you can do to flag katelynjewel:
katelynjewel consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy.
Unflagging katelynjewel will restore default visibility to their posts.
We're a place where coders share, stay up-to-date and grow their careers.
Problem-Solving Skills for Software Developers: Why & How to Improve
Problem-solving skills go hand-in-hand with software development. Learn some great problem-solving techniques and tips for improvement here!
Software developer jobs today require that you possess excellent problem-solving skills , and for good reason. Unfortunately, there seems to be a sort of talent gap when it comes to this one skill required of all software developers.
Troubleshooting and problem resolution are both informally and formally taught, but you mostly find that software developers have to learn problem-solving skills on their own. This is true for self-taught developers , obviously, but also even for those with software engineering degrees or who’ve graduated from coding boot camps.
This is why it’s necessary to acquaint yourself with the problem-solving process, whether you are a newbie or an experienced developer. In this article, we’ll explore everything you need to know about problem-solving so you can 10x your software development career.
What are Problem-Solving Skills?
As a developer, what do we mean by problem-solving? Let’s attempt a simple definition.
In software development, problem-solving is the process of using theories and research to find solutions to a problem domain, while testing different ideas and applying best practices to achieve a desired result. Problem-solving also has to do with utilizing creativity and logical thought processes to identify problems and resolve them with software.
Becoming a great software developer hinges more on learning algorithms than programming languages or frameworks . And algorithms are simply step-by-step instructions to solve a given problem.
Read More : How to Build a Software Engineer Portfolio (With Examples & Tips)
Why are impeccable problem-solving skills crucial?
Making good use of a computer language can be likened to being a skilled writer. An effective writer must know how to construct sentences and use grammar appropriately. There’s more to writing than just knowing all the words in the dictionary, and that’s how it works for developers, too.
You have different tasks to work on as a software developer, including perhaps designing, coding, and troubleshooting. Much of your time will be spent on identifying problems, spotting and correcting bugs, and making sense of codebases from before you started working there. Being ingenious at problem-solving is essential in creating incredible solutions to issues that arise throughout software development.
To demonstrate ingenuity, let’s consider Google’s autocomplete tool as an example.
The autocomplete tool is built to suggest related terms in the search bar as you type. The idea behind the tool is to reduce more than 200 years of time spent typing daily and to help users save time by up to 25% while typing.
Here’s what had to be done:
- Next, since users could type just about anything, the autocomplete suggestions had to be compiled into a sensible list dependent on user input.
- Then, Google had to create a back-end sustainability system for this function. Doing this meant massively increasing its infrastructure to accommodate all forms of data query and HTTP requests.
- Finally, the user interface had to be refined by software engineers in order to make sure that every user enjoyed a worthwhile experience. So they employed Google Trends to power the auto-completion tool while using algorithms to take out explicit or offensive predictions in line with Google’s auto-completion policy.
This is just one of Google’s innumerable problem-solving examples, but it’s clear to see that solving problems involves more than just telling a computer to do stuff. It’s about your ability to come up with parameters rightly tailored to target users so they can meet their goals.
So why must developers focus on problem-solving at work?
Software developers work with a wide range of people and departments, and it’s common to discover that some clients and teams find it difficult to define what they want. As a problem solver, it’s up to you to help them identify their needs and communicate their thoughts in an effective way.
Of course, you’ll need time and practice to develop your problem resolution ability. That’s because it’s less about solving problems faster but more about coming up with the best solution . And then you’ll need to deploy that solution.
Read More : Common Interview Questions for Software Developer Jobs (Non-Technical)
Types of problem-solving skills
Now let’s talk about four types of problem-solving skills for developers:
1. Parallel thinking
As a software developer, parallel thinking is a crucial skill necessary to perform optimally. This makes it possible for you to carry out two tasks that complement each other at the same time (like an optimized form of multitasking skills). Being able to reorder tasks to boost parallel execution can help to improve your output and save valuable time .
2. Dissecting broad and/or complex goals
When it comes to building software, you will need to effectively outline the steps and tasks necessary to achieve your goal. Developers must learn to break large and complex tasks into smaller assignments because this is an important skill that will help you create results with precision.
3. Reimplementing existing solutions
You don’t always need to reinvent the wheel. Part of being an effective software developer comes with being able to use already existing tools before even thinking of creating new solutions. Developing problem-solving skills is very much connected to finding solutions that already exist and reusing them.
Keep in mind that goals tend to evolve. So if your client comes up with new ideas, that will mean changing your design goals and reordering your tasks. A good programmer must learn to create solutions in such a way that does not require a complete redesign from scratch.
You also have to become adept at abstracting problems so that your solutions can get them resolved so long as they aren’t entirely different from the original issue. You don’t necessarily have to abstract every aspect to avoid more complications being created. This calls for balance by abstracting only where necessary without making narrow decisions.
Read More : Learn 8 Great Benefits of Working From Home
4 Important Tips & Strategies for Improving Problem-Solving Skills
To keep your problem-solving skills and techniques from growing weaker over time, you need to exercise them non-stop. As they say: practice makes perfect!
To train the problem-solving side of your brain, these four tips and strategies can help you improve your abilities:
1. Make problem-solving a part of your life
Never restrict yourself to working on problems only during work hours. Don’t make it a chore, but, instead, do things that make problem-solving look fun. The game of chess, solving puzzles, and playing video games that compel you to think critically will help strengthen your problem-solving skills, and you can tell your significant other you are advancing your career! 🙂
When you come to a complex problem in your life, whether it’s budgeting for a home or renovating the downstairs bathroom, approach it both creatively and critically. Ask yourself: What would a great software engineer do in this situation?
2. Use different platforms to solve problems
Proffer solutions to a set of problems without restricting yourself to one platform. Using different platforms and tools regularly helps make sure you become flexible as a problem-solver. And it makes sense, because there really is no universal solution for the different problems that pop up in your line of work. Trying out different platforms to solve different problems helps you to keep an open mind and enables you to test out different techniques when looking to find solutions.
Read More : 12 Common Mistakes Keeping You From Landing Your First Developer Job
3. Be open to assistance from external sources
Part of being a good software developer comes with being able to ask for help and also accept all forms of feedback. You might need a different opinion or a new set of eyes to help find the most fitting solution to some problems. It makes sense to view building problem-solving skills as more of a team effort rather than a personal journey.
Have an open mind and heart to function not only as an individual but also as a collective. It’s a utopian working environment where everyone supports each other to become better versions of themselves. So if you come across an issue that keeps you stuck, get help! You may find someone who has a more refined framework or method you never knew existed or would have thought of using. You could then learn from them and add their solution to your toolkit.
Get feedback often, as well. This could be the catalyst to making improvements to your processes and evolving them into something truly refined.
4. Tackle new problems using lessons from past solutions
As you practice and finesse your ability to identify problems and find solutions, you’ll begin to notice patterns. It’s more like developing your toolbox armed with a wide range of solutions that have proved useful in the past. So when problems emerge, you will notice how easy it is to take some of those old solutions and apply them to the new problem.
The more you attempt to apply creativity in solving problems, the more you grow your skills. In the long run, that will help you find the right solutions faster and apply them to a wide range of problems more naturally. It’s all about improving the effectiveness and efficiency with which you tackle new problems while applying only the best possible solutions.
Read More : How to Stay Motivated at Work
3 Complementary Skills to Improve to Become a Good Problem Solver
Developing software is mostly about problem-solving at the very core before even writing your first lines of code. You have to identify problems that can be solved using software. Then you have to go on to understand how people try to solve such problems in real life.
It’s up to you to come up with a framework that allows you to take both the problem and the solution and convert them into computer code. And you have to do this in such a way that makes the software even more efficient and effective than a human.
While going through this process, developers also have to handle other problems such as deadline deliveries, checking for bugs and fixing them, and collaborate across teams. So, supporting skills must not be overlooked.
Software developers must build interpersonal skills and collaboration skills . Being able to empathize, accept feedback, handle criticism, listen intently, and show respect for others are all important characteristics and abilities necessary for teamwork, and, thus, necessary for solving problems on the job.
Read More : 5 Ways to Stand Out & Get Noticed in Your Current Development Job
No one is an island, and that’s true when you consider how software engineers work. Building software requires keeping up with clients and teammates and other departments. You can’t afford to be a Lone Ranger, at least not 100% of the time, and that’s why employers always look for good communication skills.
Being a good software developer also involves how well you can break down very complex concepts to laypeople. You want to be the kind of person who fixes a problem and is able to explain how you were able to do it. It’s all about your ability to be clear and articulate about every aspect of your work. And you want to be able to communicate not just verbally but also in written form.
To build your communication skills as a developer, you can learn from more experienced people and observe how they interact with their clients. And, don’t forget, with more and more companies becoming global enterprises and going remote, it’s important to brush up on your intercultural communication skills , as well.
The difference between elite software developers and average ones is often said to be logical thinking. The ability to process thoughts logically is important, because you’ll often spend most of your time finding and fixing bugs rather than writing code.
Problems can show up from just about anywhere, even from what seems to be the most insignificant errors. So, your ability to detect software issues and solve these problems using deductive thought processes is a vital ingredient to your success as a software developer.
Read More : Questions to Ask at Interviews for Software Engineering Jobs
Problem-Solving Stages & Practices
There are countless problem-solving processes and various schools of thought regarding the best way to approach problems whenever they arise. To solve that problem, we’ve pooled some of these frameworks together to come up with a comprehensive approach to problem-solving.
Step 1 – Define the problem
You have to first start with problem identification. Knowing what you are dealing with is important, because you don’t want to risk spending valuable time applying wrong solutions. Avoid making automatic assumptions. Even when the symptoms look familiar, you want to investigate properly because such signs could be pointing to something else entirely.
Problems in software development come in different sizes and scopes. You could be having trouble getting some aspects of the product to respond in the desired way. Or maybe you’re having issues trying to decipher a codebase section where you can no longer communicate with the original developers. Sometimes, the problem could come in the form of an unfamiliar error message and you’re at loss.
Once you’re able to define the problem, make sure to document it.
Step 2 – Analyze the problem
Now it’s time to carry out problem analysis . Before deciding what problem resolution methods to adopt, it’s necessary to find out all there is to the issue, which builds on our first step. This will make it easier to come up with ideas and solutions later on.
Problem analysis isn’t always a walk in the park. There are times when the problem involves a very small mistake such as failing to import a package correctly or a small syntax error. Other times, however, it could be such a huge error, like the entire program acting differently than what you want. There might be no alarms or blinking red lights to tell you what the exact problem is.
If you encounter such situations, you can find answers by articulating the problem. Document what you intend to do, what you’ve done, the original intention for the program, and where you currently are. Communication comes in handy here, of course, not just in your documentation, but also in how you relay it to your teammates.
Read More : Got a Busy Developer Schedule? Here’s How to Keep Learning & Make Time
Step 3 – Brainstorm
This step has to do with generating ideas, and you can benefit from discussing the problem with a team and then coming up with ways to get it fixed. Keep in mind that problem-solving at work involves interacting with a diverse group of people where the individuals have unique skill sets and experiences.
Many developers tend to neglect the previous steps and rush straight into brainstorming. That’s definitely not a good way to go about problem-solving. The idea is not to skip the important steps in the process.
Once you get to the point where ideas need to be generated, do not discard any, because this step relies on a wide range of ideas. Only after gathering as many perspectives as possible should you then begin reviewing and narrowing down to the best possible solution.
Step 4 – Make a decision
At this point, all viable solutions have to be analyzed before selecting the most appropriate one to implement. Picking the best possible solution depends on its ability to meet certain criteria. It must be suitable, feasible, and then acceptable.
What it means is that the solution must be able to get the problem solved. It should also be easy to see how such a solution fits into the equation. And then every member of the team involved in the brainstorming process has to unanimously accept the solution.
Read More : How to Network as a Software Engineer
Step 5 – Implement
After identifying and choosing the solution, the next logical step is to plan out the implementation process and then execute it. Coming up with a detailed plan is crucial if the solution is to be a success.
Now this plan must detail all the necessary steps required to implement the solution. It will also explain the length of time and stages of work required. Once all of that is put in place, you can then move forward with the execution. The idea is not just to execute a solution but to do it the right way.
Implementation using automated tests can help to keep unexpected issues from arising in the future. Some other problem-solving practices or approaches begin the process with this step. So, whenever any changes are made to the project, tests asserting that the changes will perform as required will be written first before the changes are then made.
Step 6 – Evaluate
No problem-solving process can be deemed comprehensive enough if there is no room for evaluation. Whatever the solution may be, it has to undergo strict evaluation in order to see how it performs. That will also help determine whether the problem still exists and the extent to which such an issue keeps recurring.
In the event that the problem persists despite the implementation of a detailed plan, then the developer and team may even have to restart the problem-solving process. However discouraging that may sound, at least you’ll have caught it early enough. And, this also proves the process worked.
Read More : How to Become a Software Engineer: Education, Steps & Tips for Success
Developing problem-solving skills is quite necessary for software developers. To be a successful problem solver, you will need lots of years down the line to practice what you study.
Always remember that you are a problem solver first before anything else. There is more to building software than just understanding the tech behind it and writing lines of code. It’s all about improving your ability to identify problems and find solutions, and that will need lots of experience on your part.
Never shy away from problems, but learn to think critically and logically in any situation. By applying the six-step strategy for problem-solving at work discussed in this piece, you will be more equipped to come up with the most effective and efficient solutions.
We hope you enjoyed reading our guide on how to solve a problem as a software developer and ways to improve skills as a problem solver! If you have any questions, feedback, or other great problem-solving techniques or methods, let us know in the comments below 🙂
The Arc team publishes insightful articles and thought leadership pieces related to software engineering careers and remote work. From helping entry-level developers land their first junior role to assisting remote workers struggling with working from home to guiding mid-level programmers as they seek a leadership position, Arc covers it all and more!
Join the discussion Cancel reply
Save my name, email, and website in this browser for the next time I comment.
Ready to Take On a Senior Role or Leadership Position as a Developer?
Here Are 43 of the Best Online Developer Communities to Join in 2023
Here’s When You Can TRULY Call Yourself a “Senior” Software Developer
Time Management Skills for Developers: Best Tips, Tools, and Strategies
Software Engineer Degree: Pros, Cons & Alternatives
Key Analytical Skills for Developers (& How to Continually Improve Them)
- DSA for Beginners
- DSA Tutorial
- Data Structures
- Linked List
- Dynamic Programming
- Binary Tree
- Binary Search Tree
- Divide & Conquer
- Branch and Bound
- Pattern Searching
- Write an Interview Experience
- Share Your Campus Experience
What is Algorithm | Introduction to Algorithms
- What is an Algorithm? Definition, Types, Complexity, Examples
- Algorithms Design Techniques
- What is algorithm and why analysis of it is important?
Analysis of Algorithms
- Asymptotic Notation and Analysis (Based on input size) in Complexity Analysis of Algorithms
- Worst, Average and Best Case Analysis of Algorithms
- Types of Asymptotic Notations in Complexity Analysis of Algorithms
- How to Analyse Loops for Complexity Analysis of Algorithms
- How to analyse Complexity of Recurrence Relation
- Introduction to Amortized Analysis
Types of Algorithms
- Sorting Algorithms
- Searching Algorithms
- Greedy Algorithms
- Backtracking Algorithms
- Divide and Conquer
- Mathematical Algorithms
- Geometric Algorithms
- Bitwise Algorithms
- Graph Data Structure And Algorithms
- Randomized Algorithms
- Branch and Bound Algorithm
- The Role of Algorithms in Computing
- Most important type of Algorithms
Definition of Algorithm
The word Algorithm means ” A set of finite rules or instructions to be followed in calculations or other problem-solving operations ” Or ” A procedure for solving a mathematical problem in a finite number of steps that frequently involves recursive operations” .
Therefore Algorithm refers to a sequence of finite steps to solve a particular problem.
Use of the Algorithms:
Algorithms play a crucial role in various fields and have many applications. Some of the key areas where algorithms are used include:
- Computer Science: Algorithms form the basis of computer programming and are used to solve problems ranging from simple sorting and searching to complex tasks such as artificial intelligence and machine learning.
- Mathematics: Algorithms are used to solve mathematical problems, such as finding the optimal solution to a system of linear equations or finding the shortest path in a graph.
- Operations Research : Algorithms are used to optimize and make decisions in fields such as transportation, logistics, and resource allocation.
- Artificial Intelligence: Algorithms are the foundation of artificial intelligence and machine learning, and are used to develop intelligent systems that can perform tasks such as image recognition, natural language processing, and decision-making.
- Data Science: Algorithms are used to analyze, process, and extract insights from large amounts of data in fields such as marketing, finance, and healthcare.
These are just a few examples of the many applications of algorithms. The use of algorithms is continually expanding as new technologies and fields emerge, making it a vital component of modern society.
Algorithms can be simple and complex depending on what you want to achieve.
It can be understood by taking the example of cooking a new recipe. To cook a new recipe, one reads the instructions and steps and executes them one by one, in the given sequence. The result thus obtained is the new dish is cooked perfectly. Every time you use your phone, computer, laptop, or calculator you are using Algorithms. Similarly, algorithms help to do a task in programming to get the expected output.
The Algorithm designed are language-independent, i.e. they are just plain instructions that can be implemented in any language, and yet the output will be the same, as expected.
What is the need for algorithms?
- Algorithms are necessary for solving complex problems efficiently and effectively.
- They help to automate processes and make them more reliable, faster, and easier to perform.
- Algorithms also enable computers to perform tasks that would be difficult or impossible for humans to do manually.
- They are used in various fields such as mathematics, computer science, engineering, finance, and many others to optimize processes, analyze data, make predictions, and provide solutions to problems.
What are the Characteristics of an Algorithm?
As one would not follow any written instructions to cook the recipe, but only the standard one. Similarly, not all written instructions for programming are an algorithm. For some instructions to be an algorithm, it must have the following characteristics:
- Clear and Unambiguous : The algorithm should be unambiguous. Each of its steps should be clear in all aspects and must lead to only one meaning.
- Well-Defined Inputs : If an algorithm says to take inputs, it should be well-defined inputs. It may or may not take input.
- Well-Defined Outputs: The algorithm must clearly define what output will be yielded and it should be well-defined as well. It should produce at least 1 output.
- Finite-ness: The algorithm must be finite, i.e. it should terminate after a finite time.
- Feasible: The algorithm must be simple, generic, and practical, such that it can be executed with the available resources. It must not contain some future technology or anything.
- Language Independent: The Algorithm designed must be language-independent, i.e. it must be just plain instructions that can be implemented in any language, and yet the output will be the same, as expected.
- Input : An algorithm has zero or more inputs. Each that contains a fundamental operator must accept zero or more inputs.
- Output : An algorithm produces at least one output. Every instruction that contains a fundamental operator must accept zero or more inputs.
- Definiteness: All instructions in an algorithm must be unambiguous, precise, and easy to interpret. By referring to any of the instructions in an algorithm one can clearly understand what is to be done. Every fundamental operator in instruction must be defined without any ambiguity.
- Finiteness: An algorithm must terminate after a finite number of steps in all test cases. Every instruction which contains a fundamental operator must be terminated within a finite amount of time. Infinite loops or recursive functions without base conditions do not possess finiteness.
- Effectiveness: An algorithm must be developed by using very basic, simple, and feasible operations so that one can trace it out by using just paper and pencil.
Properties of Algorithm:
- It should terminate after a finite time.
- It should produce at least one output.
- It should take zero or more input.
- It should be deterministic means giving the same output for the same input case.
- Every step in the algorithm must be effective i.e. every step should do some work.
Types of Algorithms:
There are several types of algorithms available. Some important algorithms are:
1. Brute Force Algorithm :
It is the simplest approach to a problem. A brute force algorithm is the first approach that comes to finding when we see a problem.
2. Recursive Algorithm :
A recursive algorithm is based on recursion . In this case, a problem is broken into several sub-parts and called the same function again and again.
3. Backtracking Algorithm :
The backtracking algorithm builds the solution by searching among all possible solutions. Using this algorithm, we keep on building the solution following criteria. Whenever a solution fails we trace back to the failure point build on the next solution and continue this process till we find the solution or all possible solutions are looked after.
4. Searching Algorithm :
Searching algorithms are the ones that are used for searching elements or groups of elements from a particular data structure. They can be of different types based on their approach or the data structure in which the element should be found.
5. Sorting Algorithm :
Sorting is arranging a group of data in a particular manner according to the requirement. The algorithms which help in performing this function are called sorting algorithms. Generally sorting algorithms are used to sort groups of data in an increasing or decreasing manner.
6. Hashing Algorithm :
Hashing algorithms work similarly to the searching algorithm. But they contain an index with a key ID. In hashing, a key is assigned to specific data.
7. Divide and Conquer Algorithm :
This algorithm breaks a problem into sub-problems, solves a single sub-problem, and merges the solutions to get the final solution. It consists of the following three steps:
8. Greedy Algorithm :
In this type of algorithm, the solution is built part by part. The solution for the next part is built based on the immediate benefit of the next part. The one solution that gives the most benefit will be chosen as the solution for the next part.
9. Dynamic Programming Algorithm :
This algorithm uses the concept of using the already found solution to avoid repetitive calculation of the same part of the problem. It divides the problem into smaller overlapping subproblems and solves them.
10. Randomized Algorithm :
In the randomized algorithm, we use a random number so it gives immediate benefit. The random number helps in deciding the expected outcome.
To learn more about the types of algorithms refer to the article about “ Types of Algorithms “.
Advantages of Algorithms:
- It is easy to understand.
- An algorithm is a step-wise representation of a solution to a given problem.
- In an Algorithm the problem is broken down into smaller pieces or steps hence, it is easier for the programmer to convert it into an actual program.
Disadvantages of Algorithms :
- Writing an algorithm takes a long time so it is time-consuming.
- Understanding complex logic through algorithms can be very difficult.
- Branching and Looping statements are difficult to show in Algorithms (imp) .
How to Design an Algorithm?
To write an algorithm, the following things are needed as a pre-requisite:
- The problem that is to be solved by this algorithm i.e. clear problem definition.
- The constraints of the problem must be considered while solving the problem.
- The input to be taken to solve the problem.
- The output is to be expected when the problem is solved.
- The solution to this problem is within the given constraints.
Then the algorithm is written with the help of the above parameters such that it solves the problem.
Example: Consider the example to add three numbers and print the sum.
Step 1: Fulfilling the pre-requisites
As discussed above, to write an algorithm, its prerequisites must be fulfilled.
- The problem that is to be solved by this algorithm : Add 3 numbers and print their sum.
- The constraints of the problem that must be considered while solving the problem : The numbers must contain only digits and no other characters.
- The input to be taken to solve the problem: The three numbers to be added.
- The output to be expected when the problem is solved: The sum of the three numbers taken as the input i.e. a single integer value.
- The solution to this problem, in the given constraints: The solution consists of adding the 3 numbers. It can be done with the help of the ‘+’ operator, or bit-wise, or any other method.
Step 2: Designing the algorithm
Now let’s design the algorithm with the help of the above pre-requisites:
Algorithm to add 3 numbers and print their sum:
- Declare 3 integer variables num1, num2, and num3.
- Take the three numbers, to be added, as inputs in variables num1, num2, and num3 respectively.
- Declare an integer variable sum to store the resultant sum of the 3 numbers.
- Add the 3 numbers and store the result in the variable sum.
- Print the value of the variable sum
Step 3: Testing the algorithm by implementing it.
To test the algorithm, let’s implement it in C language.
Here is the step-by-step algorithm of the code:
- Declare three variables num1, num2, and num3 to store the three numbers to be added.
- Declare a variable sum to store the sum of the three numbers.
- Use the cout statement to prompt the user to enter the first number.
- Use the cin statement to read the first number and store it in num1.
- Use the cout statement to prompt the user to enter the second number.
- Use the cin statement to read the second number and store it in num2.
- Use the cout statement to prompt the user to enter the third number.
- Use the cin statement to read and store the third number in num3.
- Calculate the sum of the three numbers using the + operator and store it in the sum variable.
- Use the cout statement to print the sum of the three numbers.
- The main function returns 0, which indicates the successful execution of the program.
Time complexity: O(1) Auxiliary Space: O(1)
One problem, many solutions: The solution to an algorithm can be or cannot be more than one. It means that while implementing the algorithm, there can be more than one method to implement it. For example, in the above problem of adding 3 numbers, the sum can be calculated in many ways:
- Bit-wise operators
How to analyze an Algorithm?
For a standard algorithm to be good, it must be efficient. Hence the efficiency of an algorithm must be checked and maintained. It can be in two stages:
1. Priori Analysis:
“Priori” means “before”. Hence Priori analysis means checking the algorithm before its implementation. In this, the algorithm is checked when it is written in the form of theoretical steps. This Efficiency of an algorithm is measured by assuming that all other factors, for example, processor speed, are constant and have no effect on the implementation. This is done usually by the algorithm designer. This analysis is independent of the type of hardware and language of the compiler. It gives the approximate answers for the complexity of the program.
2. Posterior Analysis:
“Posterior” means “after”. Hence Posterior analysis means checking the algorithm after its implementation. In this, the algorithm is checked by implementing it in any programming language and executing it. This analysis helps to get the actual and real analysis report about correctness(for every possible input/s if it shows/returns correct output or not), space required, time consumed, etc. That is, it is dependent on the language of the compiler and the type of hardware used.
What is Algorithm complexity and how to find it?
An algorithm is defined as complex based on the amount of Space and Time it consumes. Hence the Complexity of an algorithm refers to the measure of the time that it will need to execute and get the expected output, and the Space it will need to store all the data (input, temporary data, and output). Hence these two factors define the efficiency of an algorithm. The two factors of Algorithm Complexity are:
- Time Factor : Time is measured by counting the number of key operations such as comparisons in the sorting algorithm.
- Space Factor : Space is measured by counting the maximum memory space required by the algorithm to run/execute.
Therefore the complexity of an algorithm can be divided into two types :
1. Space Complexity : The space complexity of an algorithm refers to the amount of memory required by the algorithm to store the variables and get the result. This can be for inputs, temporary operations, or outputs.
How to calculate Space Complexity? The space complexity of an algorithm is calculated by determining the following 2 components:
- Fixed Part: This refers to the space that is required by the algorithm. For example, input variables, output variables, program size, etc.
- Variable Part: This refers to the space that can be different based on the implementation of the algorithm. For example, temporary variables, dynamic memory allocation, recursion stack space, etc. Therefore Space complexity S(P) of any algorithm P is S(P) = C + SP(I) , where C is the fixed part and S(I) is the variable part of the algorithm, which depends on instance characteristic I.
Example: Consider the below algorithm for Linear Search
Step 1: START Step 2: Get n elements of the array in arr and the number to be searched in x Step 3: Start from the leftmost element of arr and one by one compare x with each element of arr Step 4: If x matches with an element, Print True. Step 5: If x doesn’t match with any of the elements, Print False. Step 6: END Here, There are 2 variables arr, and x, where the arr is the variable part of n elements and x is the fixed part. Hence S(P) = 1+n. So, the space complexity depends on n(number of elements). Now, space depends on data types of given variables and constant types and it will be multiplied accordingly.
2. Time Complexity : The time complexity of an algorithm refers to the amount of time required by the algorithm to execute and get the result. This can be for normal operations, conditional if-else statements, loop statements, etc.
How to Calculate , Time Complexity? The time complexity of an algorithm is also calculated by determining the following 2 components:
- Constant time part: Any instruction that is executed just once comes in this part. For example, input, output, if-else, switch, arithmetic operations, etc.
Example: In the algorithm of Linear Search above, the time complexity is calculated as follows:
Step 1: –Constant Time Step 2: — Variable Time (Taking n inputs) Step 3: –Variable Time (Till the length of the Array (n) or the index of the found element) Step 4: –Constant Time Step 5: –Constant Time Step 6: –Constant Time Hence, T(P) = 1 + n + n(1 + 1) + 1 = 2 + 3n, which can be said as T(n).
How to express an Algorithm?
- Natural Language:- Here we express the Algorithm in the natural English language. It is too hard to understand the algorithm from it.
- Flow Chart :- Here we express the Algorithm by making a graphical/pictorial representation of it. It is easier to understand than Natural Language.
- Pseudo Code :- Here we express the Algorithm in the form of annotations and informative text written in plain English which is very much similar to the real code but as it has no syntax like any of the programming languages, it can’t be compiled or interpreted by the computer. It is the best way to express an algorithm because it can be understood by even a layman with some school-level knowledge.
Solve DSA problems on GfG Practice.
Please Login to comment...
Improve your coding skills with practice.
- Social Anxiety Disorder
- Bipolar Disorder
- Kids Mental Health
- Therapy Center
- When To See a Therapist
- Types of Therapy
- Best Online Therapy
- Best Couples Therapy
- Best Family Therapy
- Managing Stress
- Sleep and Dreaming
- Understanding Emotions
- Healthy Relationships
- Relationships in 2023
- Student Resources
- Personality Types
- Verywell Mind Insights
- 2023 Verywell Mind 25
- Mental Health in the Classroom
- Editorial Process
- Meet Our Review Board
- Crisis Support
Overview of the Problem-Solving Mental Process
Kendra Cherry, MS, is a psychosocial rehabilitation specialist, psychology educator, and author of the "Everything Psychology Book."
Rachel Goldman, PhD FTOS, is a licensed psychologist, clinical assistant professor, speaker, wellness expert specializing in eating behaviors, stress management, and health behavior change.
- Identify the Problem
- Define the Problem
- Form a Strategy
- Organize Information
- Allocate Resources
- Monitor Progress
- Evaluate the Results
Frequently Asked Questions
Problem-solving is a mental process that involves discovering, analyzing, and solving problems. The ultimate goal of problem-solving is to overcome obstacles and find a solution that best resolves the issue.
The best strategy for solving a problem depends largely on the unique situation. In some cases, people are better off learning everything they can about the issue and then using factual knowledge to come up with a solution. In other instances, creativity and insight are the best options.
It is not necessary to follow problem-solving steps sequentially, It is common to skip steps or even go back through steps multiple times until the desired solution is reached.
In order to correctly solve a problem, it is often important to follow a series of steps. Researchers sometimes refer to this as the problem-solving cycle. While this cycle is portrayed sequentially, people rarely follow a rigid series of steps to find a solution.
The following steps include developing strategies and organizing knowledge.
1. Identifying the Problem
While it may seem like an obvious step, identifying the problem is not always as simple as it sounds. In some cases, people might mistakenly identify the wrong source of a problem, which will make attempts to solve it inefficient or even useless.
Some strategies that you might use to figure out the source of a problem include :
- Asking questions about the problem
- Breaking the problem down into smaller pieces
- Looking at the problem from different perspectives
- Conducting research to figure out what relationships exist between different variables
2. Defining the Problem
After the problem has been identified, it is important to fully define the problem so that it can be solved. You can define a problem by operationally defining each aspect of the problem and setting goals for what aspects of the problem you will address
At this point, you should focus on figuring out which aspects of the problems are facts and which are opinions. State the problem clearly and identify the scope of the solution.
3. Forming a Strategy
After the problem has been identified, it is time to start brainstorming potential solutions. This step usually involves generating as many ideas as possible without judging their quality. Once several possibilities have been generated, they can be evaluated and narrowed down.
The next step is to develop a strategy to solve the problem. The approach used will vary depending upon the situation and the individual's unique preferences. Common problem-solving strategies include heuristics and algorithms.
- Heuristics are mental shortcuts that are often based on solutions that have worked in the past. They can work well if the problem is similar to something you have encountered before and are often the best choice if you need a fast solution.
- Algorithms are step-by-step strategies that are guaranteed to produce a correct result. While this approach is great for accuracy, it can also consume time and resources.
Heuristics are often best used when time is of the essence, while algorithms are a better choice when a decision needs to be as accurate as possible.
4. Organizing Information
Before coming up with a solution, you need to first organize the available information. What do you know about the problem? What do you not know? The more information that is available the better prepared you will be to come up with an accurate solution.
When approaching a problem, it is important to make sure that you have all the data you need. Making a decision without adequate information can lead to biased or inaccurate results.
5. Allocating Resources
Of course, we don't always have unlimited money, time, and other resources to solve a problem. Before you begin to solve a problem, you need to determine how high priority it is.
If it is an important problem, it is probably worth allocating more resources to solving it. If, however, it is a fairly unimportant problem, then you do not want to spend too much of your available resources on coming up with a solution.
At this stage, it is important to consider all of the factors that might affect the problem at hand. This includes looking at the available resources, deadlines that need to be met, and any possible risks involved in each solution. After careful evaluation, a decision can be made about which solution to pursue.
6. Monitoring Progress
After selecting a problem-solving strategy, it is time to put the plan into action and see if it works. This step might involve trying out different solutions to see which one is the most effective.
It is also important to monitor the situation after implementing a solution to ensure that the problem has been solved and that no new problems have arisen as a result of the proposed solution.
Effective problem-solvers tend to monitor their progress as they work towards a solution. If they are not making good progress toward reaching their goal, they will reevaluate their approach or look for new strategies .
7. Evaluating the Results
After a solution has been reached, it is important to evaluate the results to determine if it is the best possible solution to the problem. This evaluation might be immediate, such as checking the results of a math problem to ensure the answer is correct, or it can be delayed, such as evaluating the success of a therapy program after several months of treatment.
Once a problem has been solved, it is important to take some time to reflect on the process that was used and evaluate the results. This will help you to improve your problem-solving skills and become more efficient at solving future problems.
A Word From Verywell
It is important to remember that there are many different problem-solving processes with different steps, and this is just one example. Problem-solving in real-world situations requires a great deal of resourcefulness, flexibility, resilience, and continuous interaction with the environment.
Get Advice From The Verywell Mind Podcast
Hosted by therapist Amy Morin, LCSW, this episode of The Verywell Mind Podcast shares how you can stop dwelling in a negative mindset.
Follow Now : Apple Podcasts / Spotify / Google Podcasts
You can become a better problem solving by:
- Practicing brainstorming and coming up with multiple potential solutions to problems
- Being open-minded and considering all possible options before making a decision
- Breaking down problems into smaller, more manageable pieces
- Asking for help when needed
- Researching different problem-solving techniques and trying out new ones
- Learning from mistakes and using them as opportunities to grow
It's important to communicate openly and honestly with your partner about what's going on. Try to see things from their perspective as well as your own. Work together to find a resolution that works for both of you. Be willing to compromise and accept that there may not be a perfect solution.
Take breaks if things are getting too heated, and come back to the problem when you feel calm and collected. Don't try to fix every problem on your own—consider asking a therapist or counselor for help and insight.
If you've tried everything and there doesn't seem to be a way to fix the problem, you may have to learn to accept it. This can be difficult, but try to focus on the positive aspects of your life and remember that every situation is temporary. Don't dwell on what's going wrong—instead, think about what's going right. Find support by talking to friends or family. Seek professional help if you're having trouble coping.
Davidson JE, Sternberg RJ, editors. The Psychology of Problem Solving . Cambridge University Press; 2003. doi:10.1017/CBO9780511615771
Sarathy V. Real world problem-solving . Front Hum Neurosci . 2018;12:261. Published 2018 Jun 26. doi:10.3389/fnhum.2018.00261
By Kendra Cherry, MSEd Kendra Cherry, MS, is a psychosocial rehabilitation specialist, psychology educator, and author of the "Everything Psychology Book."
By clicking “Accept All Cookies”, you agree to the storing of cookies on your device to enhance site navigation, analyze site usage, and assist in our marketing efforts.
- Computers & Technology
Enjoy fast, FREE delivery, exclusive deals and award-winning movies & TV shows with Prime Try Prime and start saving today with Fast, FREE Delivery
Amazon Prime includes:
Fast, FREE Delivery is available to Prime members. To join, select "Try Amazon Prime and start saving today with Fast, FREE Delivery" below the Add to Cart button.
- Cardmembers earn 5% Back at Amazon.com with a Prime Credit Card.
- Unlimited Free Two-Day Delivery
- Instant streaming of thousands of movies and TV episodes with Prime Video
- A Kindle book to borrow for free each month - with no due dates
- Listen to over 2 million songs and hundreds of playlists
- Unlimited photo storage with anywhere access
Important: Your credit card will NOT be charged when you start your free trial or if you cancel during the trial period. If you're happy with Amazon Prime, do nothing. At the end of the free trial, your membership will automatically upgrade to a monthly membership.
Buy new: $44.95 $44.95 FREE delivery: Friday, Sep 8 Payment Secure transaction Ships from Amazon.com Sold by Amazon.com Returns Eligible for Return, Refund or Replacement within 30 days of receipt
- Free returns are available for the shipping address you chose. You can return the item for any reason in new and unused condition: no shipping charges
- Learn more about free returns.
- Go to your orders and start the return
- Select the return method
Buy used: $34.94
Fulfillment by Amazon (FBA) is a service we offer sellers that lets them store their products in Amazon's fulfillment centers, and we directly pack, ship, and provide customer service for these products. Something we hope you'll especially enjoy: FBA items qualify for FREE Shipping and Amazon Prime.
If you're a seller, Fulfillment by Amazon can help you grow your business. Learn more about the program.
Other Sellers on Amazon
Download the free Kindle app and start reading Kindle books instantly on your smartphone, tablet, or computer - no Kindle device required . Learn more
Read instantly on your browser with Kindle for Web .
Using your mobile phone camera - scan the code below and download the Kindle app.
Follow the Author
Problem Solving with Algorithms and Data Structures Using Python SECOND EDITION 2nd Edition
- Paperback $34.94 - $44.95 10 Used from $20.66 9 New from $40.94
There is a newer edition of this item:
Purchase options and add-ons
- ISBN-10 1590282574
- ISBN-13 978-1590282571
- Edition 2nd
- Publisher Franklin, Beedle & Associates
- Publication date August 22, 2011
- Language English
- Dimensions 7.5 x 0.9 x 9.2 inches
- Print length 438 pages
- See all details
Frequently bought together
Customers who viewed this item also viewed
- Publisher : Franklin, Beedle & Associates; 2nd edition (August 22, 2011)
- Language : English
- Paperback : 438 pages
- ISBN-10 : 1590282574
- ISBN-13 : 978-1590282571
- Item Weight : 1.7 pounds
- Dimensions : 7.5 x 0.9 x 9.2 inches
- #6 in Data Structure and Algorithms
- #95 in Computer Programming Languages
- #202 in Python Programming
To report an issue with this product, click here .
About the author
Bradley n. miller.
Discover more of the author’s books, see similar authors, read author blogs and more
Customer Reviews, including Product Star Ratings help customers to learn more about the product and decide whether it is the right product for them.
To calculate the overall star rating and percentage breakdown by star, we don’t use a simple average. Instead, our system considers things like how recent a review is and if the reviewer bought the item on Amazon. It also analyzed reviews to verify trustworthiness.
Reviews with images
Submit a report
- Harassment, profanity
- Spam, advertisement, promotions
- Given in exchange for cash, discounts
Sorry, there was an error
Read reviews that mention.
- Sort reviews by Top reviews Most recent Top reviews
Top reviews from the United States
There was a problem filtering reviews right now. please try again later..
Top reviews from other countries
- Amazon Newsletter
- About Amazon
- Press Center
- Investor Relations
- Amazon Devices
- Amazon Science
- Sell more with Amazon
- Sell apps on Amazon
- Supply to Amazon
- Protect & Build Your Brand
- Become an Affiliate
- Become a Delivery Driver
- Start a Package Delivery Business
- Advertise Your Products
- Self-Publish with Us
- Host an Amazon Hub
- › See More Ways to Make Money
- Amazon Visa
- Amazon Store Card
- Amazon Secured Card
- Amazon Business Card
- Shop with Points
- Credit Card Marketplace
- Reload Your Balance
- Amazon Currency Converter
- Your Account
- Your Orders
- Shipping Rates & Policies
- Amazon Prime
- Returns & Replacements
- Manage Your Content and Devices
- Your Recalls and Product Safety Alerts
- Conditions of Use
- Privacy Notice
- Your Ads Privacy Choices
What is Microsoft’s “Algorithm of Thoughts” and how does it enhance AI reasoning?
In a significant leap forward for artificial intelligence (AI) research, Microsoft has introduced a groundbreaking AI training technique known as the “Algorithm of Thoughts” (AoT). Designed to bridge the gap between human-like intuition and algorithmic precision, this approach aims to enhance the reasoning abilities of large language models, propelling AI technology further towards human-like cognition.
Microsoft’s AI advancement with Algorithm of Thoughts
Tech industry giant Microsoft has unveiled a pioneering AI training methodology named the “Algorithm of Thoughts” (AoT), representing a crucial advancement in the realm of artificial intelligence. With a focus on bolstering the capabilities of large language models, such as ChatGPT, this innovative technique combines the strengths of human cognitive processes with the systematic logic of algorithms. The AoT technique arrives as the next logical step for Microsoft, which has demonstrated steadfast commitment to AI research and development, notably through its significant investments in OpenAI and its portfolio of influential language models.
According to a research paper published by Microsoft, the Algorithm of Thoughts presents a transformative opportunity to elevate AI reasoning. The method operates by guiding a language model along a streamlined pathway in problem-solving, harnessing the power of “in-context learning.” This strategic approach empowers the AI model to navigate various solution avenues in an organized and systematic manner, culminating in swifter and less resource-intensive problem-solving capabilities.
The research paper discusses the superiority of the Algorithm of Thoughts over earlier single-query methods, highlighting its comparable performance to a recent multi-query technique that extensively employs tree search. Interestingly, the results indicate that guiding a model with an algorithm can result in performance that surpasses the algorithm’s own capabilities. This remarkable phenomenon underscores the potential of the AoT technique to not only match but exceed the capabilities of conventional algorithmic methods.
A human-algorithmic fusion for enhanced reasoning
Under the AoT banner, Microsoft’s approach signifies a convergence of human and algorithmic attributes, yielding a hybrid methodology that transcends the limitations of existing AI training techniques. Drawing inspiration from both human intuition and machine-driven exhaustive exploration, AoT seeks to optimize the reasoning prowess of generative AI models. In the research paper, the concept is further explored, with the statement that the Algorithm of Thoughts seeks to combine these two aspects to enhance the reasoning abilities within large language models (LLMs).
The AoT technique emerges as a response to the shortcomings observed in prevalent in-context learning methodologies like the “Chain-of-Thought” (CoT) approach. Unlike CoT, which occasionally yields incorrect intermediate steps, AoT employs algorithmic examples to guide the AI model towards more accurate and reliable results. This amalgamation of human-like intuition and structured algorithmic guidance establishes a unique synergy that propels the AI model’s problem-solving proficiency.
Advancing AI’s problem-solving potential
The novel AoT method represents a pivotal shift from conventional supervised learning approaches, introducing the incorporation of the search process itself. As researchers refine prompt engineering and fine-tune this hybrid technique, it holds the promise of transforming AI models into adept problem solvers, capable of efficiently tackling intricate real-world challenges while simultaneously reducing their environmental impact.
Microsoft’s extensive investments in the field of AI position the company to seamlessly integrate the Algorithm of Thoughts into its forthcoming advanced systems, potentially including the highly anticipated GPT-4. While the journey to imbuing language models with human-like reasoning is undoubtedly challenging, AoT’s introduction marks a significant stride towards achieving this transformative goal. As AI technology continues to evolve, the Algorithm of Thoughts emerges as a pioneering methodology that could redefine the landscape of AI reasoning, ushering in an era of more intuitive and sophisticated problem-solving capabilities.
- Previous Article
- Next Article
Numerical algorithm of gravity inverse problem solving for layered medium
- Article contents
- Figures & tables
- Supplementary Data
- Peer Review
- Open the PDF for in another window
- Reprints and Permissions
- Cite Icon Cite
- Search Site
Petr S. Martyshko , Denis D. Byzov , Igor V. Ladovskii; Numerical algorithm of gravity inverse problem solving for layered medium. AIP Conference Proceedings 1 September 2023; 2849 (1): 190009. https://doi.org/10.1063/5.0162277
Download citation file:
- Ris (Zotero)
- Reference Manager
We suggest a performance-effective method of the gravity field separating, which is based on using the modified local correction numerical algorithm. Algorithm stability is ensured step-by-step in the problem solving on a correctness set only. Using separated field anomalies from the layers, the 3D density distribution is restored in a form of a 3D grid. We illustrated the method effectiveness on an example with practical interpretation.
Citing articles via
Publish with us - request a quote.
- Online ISSN 1551-7616
- Print ISSN 0094-243X
- For Researchers
- For Librarians
- For Advertisers
- Our Publishing Partners
- Physics Today
- Conference Proceedings
- Special Topics
Connect with AIP Publishing
This feature is available to subscribers only.
Sign In or Create an Account
Problem Solved - New course partners students with real companies on product development
It’s no secret that students learn best when they can apply lessons from the classroom to real-world challenges. Indeed, transformative learning opportunities like corporate consulting projects are central to the mission of Purdue’s newly reimagined Mitchell E. Daniels, Jr. School of Business.
Among the school’s experiential learning offerings is a new course, Problem Solving in the Business World (MGMT 332), that guides students through a six-week product development project with company partners Whirlpool and dormakaba. The course is taught by alumnus Dave Randich, former president of MasterBrand Cabinets and a Daniels School lecturer in Law, Communication, and Ethics.
“I wanted students to learn about product development from an inside-the-business perspective,” Randich says. “The goal was for them to use the same skills they would as future managers and to see themselves working in a professional setting.”
The partnerships were facilitated by Jess Franta, managing director of the Daniels School’s Business Partnerships Office. “We were looking for companies with a tangible product in mind and a willingness for creative thinking and innovation,” she says. “We also wanted companies that had been good partners in the past and would be exciting for the students to work with.”
Following ten weeks of classroom instruction, students in the course formed teams to work directly with their respective partner company to develop an idea for a new product. Their tasks included a market analysis and value proposition, an innovation overview, an operations and supply chain overview, and new product financial metrics. The teams met weekly with company representatives before presenting their ideas to management.
Logan Paul, a junior studying economics, was on a team that partnered with Whirlpool’s Kitchen-Aid consumer appliance division. “This course taught me everything that goes into creating a new product and presenting it in a professional setting, from product ideation to production and packaging,” he says. “My biggest takeaways were the lessons it taught me about problem solving and working in a group.”
“The Daniels School is taking active steps to ensure their students join the workforce prepared with a knowledge of business vocabulary and business plan development.”
- Justin Crotzer, Senior Vice President of Product Development, dormakaba
Hannah Baird, Whirlpool’s facilitator for the course, says the students asked insightful questions and approached the case study with excitement and fresh perspectives.
“I was impressed by their willingness to think outside of the box of what we currently offer and start with the end consumer in mind,” she says. “Also, their attention to detail with every section we touched on was visible throughout their final presentations. They really took the time to apply what we went through to give some top-notch recommendations.”
Justin Crotzer, a Purdue engineering alumnus and senior vice president of product development at dormakaba, led his company’s involvement in the course.
“The course provided a clear demonstration of Purdue’s investment in essential real-life business planning, strategic thinking, and presentation professionalism,” Crotzer says. “The Daniels School is taking active steps to ensure their students join the workforce prepared with a knowledge of business vocabulary and business plan development.”
Alex Housten, president of dormakaba, came away from the course equally enthused. “The Purdue MGMT 332 students brought energy, innovation, and fresh eyes to our business, enabling a renewed approach to success in this market,” he says. “Dave Randich guided a structured and paced process that added real value to dormakaba.”
In addition to providing Whirlpool and dormakaba with new product ideas, the course allowed the companies to create a pipeline of future talent.
“They spent a lot of time selling their companies to the students,” Randich says. “It was a great opportunity for students to integrate and interact with the company and put themselves in a position for internships or full-time employment.”
Whirlpool’s Laird agrees. “Course partnerships are probably one of the best strategies we can leverage to start scouting top talent early on,” she says. “Working with classes offers an opportunity to be first in those students' minds when they think of companies they may aspire to work for one day.”
The course, which aligns with Purdue’s Transformative Education 2.0 initiative, is also an example of how the Daniels School is integrating experiential learning and innovative company engagement across the curriculum. By switching the learning experience from passive to active, the school produces agile, critical thinkers capable of identifying and solving the world’s biggest problems.
“What's been most important is building a strong match between what students are looking for, what their academic and professional goals are, and allowing them to transfer that into the working world through academic projects,” says Franta. “It all begins with an initial conversation about the business challenge that we're hoping to solve and how Purdue and the business school can make that happen.”