How to get better at data structures and algorithms in 7 easy stages

 

Step 1: Recognize depth vs breadth

ADS

Everyone has a friend who has mastered 500 coding challenges. They cherish donning it as a badge of courage. However, they completely bomb at interviews. This situation occurs frequently. We refer to it as the "Breadth-Only" strategy. They are just concerned with finding solutions to as many issues as they can.

A weakness of the breadth-only strategy is that a solid foundation isn't established. Deep understanding of problem-solving techniques and quick, correct coding skills are essential for interviews. These abilities can only be acquired via careful preparation.

Here is a method that seems counterintuitive but more effective:

Focus on fewer issues rather than more

You must find this soothing. Who wants to concentrate on 500 issues when they can concentrate on 100?

The important thing is to really learn them, though. Herein lies the importance of depth.


When you thoroughly evaluate a problem, it means:

1.You're quick at coding.
2.You are proficient in the language because you can code it correctly.
3.Because it comes naturally to you, you can create clean code in one sitting.
4.You may rapidly use the same code to solve a new problem.
5.You are familiar with the data structure you are utilizing and are capable of implementing it.

You must concentrate on a few sample issues in order to do this (around 100 works well.) Once you've solved them a few times, you'll begin to notice trends. Additionally, you start to improve your coding skills.

So, you have to you for covering Depth! You now have a strong foundation.

Now is the time to go all out and address as many issues as you wish. The nice part is that not many of them will require coding. Find a solution, and if it resembles one of your fundamental issues (which it frequently does), you're done. You're already skilled at it, therefore there's no need to actually develop and debug it.

Step 2: Begin the Depth-First Approach by creating a list of fundamental inquiries.

Make a list of 100 fundamental issues. You may find 100 handpicked puzzles on several websites.

Here is another approach:

get these two books
  1. elements of programming interviews
  2. cracking the coding interviews
Together, they provide you with a decent selection of specially chosen tasks. Visit InterviewCamp.io if you want a formal course for this.

Step 3:Learn each data structure in step three.

Start with the fundamentals now that your list has been determined. understand each data structure.


Study each data structure in your language and how to use it.

also learn how to put them into practice. Yes, carry them out by hand. This is often disregarded, yet it's crucial. You may be questioned about data structure internals in interviews. Many issues alter data structures or re-design them to fit a particular use case. You must understand how they operate in order to make full use of them.

For instance:

You initialized an array-backed list, the interviewer said. Good. When you try to add another element, what happens if you reach its capacity?
Who should run for office: "What do you mean capacity? I can keep expanding this list with new items.

Interviewer: "facepalm"

The applicant in this scenario was utilizing Python, which has no idea of list capacity. You just keep adding components. However, that is not actually how things work. You must be aware of the data structures that support lists and how they function.

Here’s another example:

Imagine that you are required to implement a queue only utilizing stacks (a popular question). This data structure has been altered. You'll have problems getting started if you haven't used any of those previously.

Become familiar with the following data structures:
Lists and Arrays
2D array
Linked List
Strings 
Stack
Queue
Heap
 Graphs
 Hash Tables and Hash Sets
Binary Search Tree 
Trie 
Binary Tree

How do you approach it? Let's assume that your primary issues are split up by data structure. When you begin each part, you may master every data structure. Alternately, you may learn them all at once. Go with what suits you.

Step 4: spaced Repetition

Alright. You compiled a list of inquiries and got to work answering them. Here is a typical query we get:

"I can answer a lot of things, but a week later I can't! How do I remember the answers?

The secret is to avoid remembering answers. The secret is to put them to use. You should be able to deconstruct an issue and recreate the answer as soon as you perceive one. This is distinct from learning through repetition. You're identifying various elements, dissecting them, and resolving the issue.

The best method we've observed is to solve the issue once more in three days. the next week. the next month. You'll start to do it naturally.

Step 5: Identify reusing strategies. Separate out the actual code pieces.

The Depth-First methodology starts at this point. You'll begin to see patterns as you work through these issues.

Say you utilized Binary Search to solve five issues. The Binary Search code may be isolated and repeatedly practiced. You anticipate applying it to issues of a same nature.

And among the various strategies you may choose from is this one. Other such examples are as follows:
  • Depth first search
  • Memorization + repetition
  • Combination of Linked List and Hash Table
  • Searching a binary tree etc...

 Step 6: The next step is breadth.

Let's assume that you have conquered your primary issues. You're comfortable with using standard data structures. You may now expand your search outside your existing set of skills. You don't even need to code all the new questions because you've already used so many strategies.

Try to tackle practical interview difficulties at this period. Once you get proficient, you may start concentrating on very challenging issues. If I can figure out these very challenging issues, interview questions will be easy, the thinking goes. Typically, that is not the case. Really difficult issue solving strategies frequently have little to do with difficulties found in interviews.

Step 7: Exercise using paper.

At some point during your preparation, we advise practicing on paper. Coding without an IDE and Stack Overflow forces you to step outside of your comfort zone.

The following are some advantages to practicing on paper:
  • You must organize your code before writing it. You are unable to just retype.
  • yastmastmastmastmastmastmas, and Code used to write itself while using an IDE.
  • Anywhere you go, you may practice with a piece of paper and a pen.

Post a Comment

0 Comments