Hashing is the process of converting a given key into another smaller value for O(1) retrieval time.

  • This is done by taking the help of some function or algorithm which is called a hash function to map data to some encrypted or simplified representative value which is termed as “hash code” or “hash”. This hash is then used as an index to narrow down search criteria to get data quickly.
Image for post
Image for post
  • Hashing can be considered as a significant improvement over DAT to reduce the space complexity.
  • In our example of the employee system that we have seen in the introduction part, we can simply pass the employee ID to our hash function, get the hash code and use…

A greedy algorithm is a simple and efficient algorithmic approach for solving any given problem by selecting the best available option at that moment of time, without bothering about the future results.

  • In simple words, here, it is believed that the locally best choices made would be leading towards globally best results.
  • In this approach, we never go back to reverse the decision of selection made which is why this algorithm works in a top-bottom manner.

Advantages of Greedy Approach:

  • It is easier to describe.
  • It can perform better in most of the scenarios than other algorithms.
NOTE: We have mentioned “in most of the scenarios” in the earlier point because in some cases, this approach doesn’t always produce correct results due to the nature of not reversing the decision made. …


There are 2 popular approaches of doing graph traversals :
* Depth first search ( DFS )
* Breadth first search ( BFS )

Example Implementation Of Bfs And Dfs

DFS Algorithmic Steps

Step 1: Push the root node in the Stack.
Step 2: Loop until stack is empty.
Step 3: Peek the node of the stack.
Step 4: If the node has unvisited child nodes, get the unvisited child node, mark it as traversed and push it on stack.
Step 5: If the node does not have any unvisited child nodes, pop the node from the stack.

Based upon the above steps, the following Java code shows the…


Backtracking is an algorithmic technique that considers searching in every possible combination for solving a computational problem.

  • It is known for solving problems recursively one step at a time and removing those solutions that do not satisfy the problem constraints at any point in time.
  • It is a refined brute force approach that tries out all the possible solutions and chooses the best possible ones out of them.
  • The backtracking approach is generally used in cases where there are possibilities of multiple solutions.
The term backtracking implies - if the current solution is not suitable, then eliminate that and backtrack (go back) and check for other solutions.

Backtracking — How it works?

In any backtracking problems, the algorithm tries to find a…


Sorting Algorithms are methods of reorganizing a large number of items into some specific order such as highest to lowest, or vice-versa, or even in some alphabetical order.

These algorithms take an input list, processes it (i.e, perform some operations on it) and produce the sorted list.

The most common example we experience every day is sorting clothes or other items on an e-commerce website either by lowest-price to highest, or list by popularity, or some other order.

Image for post
Image for post

Sort Implementation Details

C++ Sorting vector V,

sort(V.begin(), V.end());

Bubble Sort

Bubble sort, also referred to as comparison sort, is a simple sorting algorithm that repeatedly goes through the list, compares adjacent elements and swaps them if they are in the wrong order. This is the most simplest algorithm and inefficient at the same time…


Maths ( especially discrete mathematics ) and computer science go very much hand in hand.

Factorization

The factor of a number, N is a number d such that d divides N.
That is, N % d == 0.

Example:

For number 6, the factors are 1, 2, 3 and 6.

Question 1: All Factors

Given a number N, find all factors of N.

N = 6
factors = {1, 2, 3, 6}

Solution

Image for post
Image for post

Time Complexity: O(sqrt(n))

Question 2: Verify Prime

Given a number N, verify if N is prime or not.

Solution


So, two-pointer ( or N pointer for that matter ) is usually a really clever optimization on some brute force approaches in certain conditions.

Let us start looking at this with the help of a question. Then we will generalize our approach.

Question 1:

Given a sorted array A ( sorted in ascending order ),
find if there exists 2 integers A[i] and A[j] such that A[i] + A[j] = 0, i != j

Now the naive solution would be,

Image for post
Image for post

This solution is O(n²).

However, let us now analyze how ‘i’ and ‘j’ move with iterations. Clearly, ‘i’ moves forward with every…


A *writes down "1+1+1+1+1+1+1+1 =" on a sheet of paper*

A : "What's that equal to?"
B : *counting* "Eight!"

A *writes down another "1+" on the left*
A : "What about that?"
B : *quickly* "Nine!"
A : "How'd you know it was nine so fast?"
A : "You just added one more"
A : "So you didn't need to recount because you remembered there were eight! Dynamic Programming is just a fancy way to say 'remembering stuff to save time later'"

This conversation has the essence of dynamic programming.

The idea is very simple, If you have solved…


React, a javascript library for building user interfaces. Developed at Facebook and released in 2013 it’s safe to say React has been the most influential ui library of recent memory.

Components

We use it to build components that represent logical reusable parts of the UI.

Image for post
Image for post

The beauty of React is that the simplicity of building a component has been brought down to its theoretical minimum. It’s just a javascript function. The return value from this function is your HTML or ui which is written in a special syntax called JSX allowing you to easily combine javascript with HTML markup.


October 23rd, 2019, Google announces it as achieve the impossible goal of quantum supremacy, a machine more than 100 million times faster than your 16 inch MacBook. Only one month later AWS releases quantum computing as a service in the cloud.

If you’re a software developer in today’s world if there’s a good chance your infrastructure is on the cloud and very likely with a big provider like AWS Azure, DCP, or IBM. …

Tech Bro

Technical Details behind all your favorite products.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store