Join me to stay up-to-date and get my new articles delivered to your inbox by subscribing here.
A web crawler service, such as Google Search, is a system that automatically visits web pages and retrieves information from them. It is used to index web pages for search engines, monitor websites for changes, and create web archives. The web crawler service consists of several components: • Web Crawler: This is the main component […]
Introduction This generator class provides methods for creating various graphs, including Erdos-Renyi random graphs, random bipartite graphs, random k-regular graphs, and random rooted trees. There is also a dependency on the Undirected Graphs class. Functions simple Returns a random simple graph containing V vertices and E edges. simple_erdos_renyi Returns a random simple graph on V […]
An excerpt from the book Algorithms (4th Edition) by Robert Sedgewick and Kevin Wayne. And I also added a python implementation. Definitions Graph Representation Alternatives We have 2 basic requirements to choose the best graph representation (data structure) to use. Adjacency Matrix We maintain a V-by-V boolean array, with the entry in row v and […]
Python Implementation This implementation uses an indexed minimum priority queue data structure.
Motivation As stated here, a priority queue is an abstract data type similar to a regular queue or stack data structure in which each element additionally has a priority associated with it. The most common functions of priority queues are push and pop operations as same as regular queues. The time complexities of push and […]
Question Given an integer N, find the greatest integer less than N and has the same digits. If there is no such integer, return -1. For example: Input = 630 Output = 603 Input = 603 Output = 360 Input = 360 Output = 306 Input = 306 Output = -1 (Be careful, 063 could […]
Question Imagine an array that contains both integers and nested arrays, such as the following: [[2, [9, 1, 3], 8], 1, 4]. The depth sum is described as the weighted sum of each integer, weighted by their respective depths. In the example, 9’s depth is 3, while 8’s depth is 2, and 4’s depth is […]
Introduction I reviewed some implementations of the median function in widely used statistics packages. They use simple flow like sorting the array and returning the middle element.The average runtime complexity of comparison-based sorting algorithms is linearithmic -> O(N log N)And choosing the middle element is of constant runtime complexity -> O(1)So the runtime complexity of […]