Web scraping in Java – Jsoup and selenium

web scraping feature

Web scraping is a great way to retrieve data and save the information. with a simple Java web scraping setup, you can download content using Jsoup and selenium. Download the source code from the GitHub. Table of Content Web scraping and parsing in HTML – Jsoup Download images – Jsoup …

Continue reading

Get suggested friends (2 solutions) – DFS and Union Find

suggested friends

Get suggested friends is one of a coding question in social network applications. The data structures for social network is usually a graph. In the graph, you can use depth first search(DFS) or breadth first search(BFS) to find the connections between people. Alternatively, you can also use Union find to …

Continue reading

Hierholzer’s algorithm to find an Euler path

longest path

An Euler path  is a trail in a graph that visits every edge exactly once. Here we use graph data structure to simulate the set of linked porker cards and find the Euler path between them. In a porker game, if two poker cards have matched suites and figures, they can be link together. Given …

Continue reading

Modulo operation and circular array

modulo operation

The modulo operation returns the remainder of one number divided by another. Modulo operator is a arithmetical operator, represented as %. For example, 6 % 4 is 2. The modulo operation is very useful in circular array. When an array index modulo (or mod) the array length, the index that …

Continue reading

Topological sort using DFS and BFS

Tournamnet ranking

Topological sort is a graph traversal in which node v is visited only after all its dependencies are visited. The graph has to be directed and has no cycles, i.e. directed acyclic graph (DAG). Once the graph is built, you can use the algorithms to find the order. The result …

Continue reading

Word ladder using bidirectional BFS

word ladder bidirectional bfs

Word ladder is to find the number of steps to convert one string to another by changing one letter at a time. The intermediate words should be valid and can be found in pre-defined dictionary. The intuitive solution is using breadth first search (BFS). It starts from the original word, …

Continue reading

Autocorrect and edit distance problem in Java

autocorrect java

When you search in Google, it provides autocorrect for validating the keywords you enter into the input box. Behind the scene, it checks the input words against a dictionary. If it doesn’t find the keyword in the dictionary, it suggests a most likely replacement. Here I introduce a simple solution …

Continue reading

Software Engineering Concepts – Student Guide

SW overview

This post is an illustrated explanation of Software Engineering Concepts and terminologies. It helps you to decide which areas you would like to specialize in. Table of Content Mathematics Systems Programming Networks Data Science Applications Artificial intelligence For your consideration 1. Mathematics Mathematics is an important foundation for all science …

Continue reading

Domino Eulerian path problem using backtracking

dominoes euler path

A Euler path (Eulerian path) is a path in a graph that you visit each edge exactly once. You can visit the same vertex multiple times though. Dominoes is one example of finding Euler path problem. A domino is a game piece that has 2 numbers on it, one number …

Continue reading

Clean directories using recursion – code

delete files older than n days

Delete files older than n days and remove the empty directories after the files are deleted. This can be done using recursion. Recursion is a technique that a function calls itself.  When the base condition is met, the rest of call stacks return from the last call to the first. …

Continue reading