Design - An LRU cache should support the operations: lookup, insert and delete. Apparently, in order to achieve fast lookup, we need to use hash. By the same token, if we want to make insert/delete fast, something like linked list should come to your mind. Since we need to locate the least recently used item… Continue reading LRU Cache Design

# Author: Anil Singh

## General Question

1. Have you ever looked at the source code of the libraries/frameworks you use? A. Monolog, Dispatcher, League\Csv\Writer 2. How do you organize your code? A. 3. Describe two good uses - and practices - for callback usage. 4. HMVC Pros and Cons - HMVC can do anything that MVC can and more...one of… Continue reading General Question

## Monolog

Monolog is a logging library and provides a simple way to log to different logging means like to logstash, sentry, redis etc... We need to configure Monolog handler as per our need. Suppose we need to configure Monolog to send logs to Logstash. Check this blogCheck this blog (If you set up everything correctly, Monolog is… Continue reading Monolog

## Reflection Class

Usage - Dynamic typing is probably impossible without reflection. Aspect Oriented Programming listens from method calls and places code around methods, all accomplished with reflection. PHPUnit relies heavily on reflection, as do other mocking frameworks. Really good article to read - ** https://code.tutsplus.com/tutorials/reflection-in-php--net-31408 *http://culttt.com/2014/07/02/reflection-php/

## Design a Web Crawler

JADM_Volume 2_Issue 1_Pages 25 - Page rank algo. -31Parallel_crawler_architecture_and_web_page_change_- How to detect change in web page change in content. It's basically a directed graph - nodes are website and link are edges. Have a crawler which starts at some authoritative news or other website. To take note of - We need to respect the robot.txt on… Continue reading Design a Web Crawler

## Ordered Set

An ordered set is same as the sorted set data structure in Redis. An ordered set can be implemented using a number of data structure. Like the sorted set in Redis is implemented using Skip List. It can be implemented using AVL tree, Red-Black Tree, Splay Tree. An ordered set is a common data structure that… Continue reading Ordered Set

## Gnutella Working

Video How a Gnutella client finds a song Given that there is no central server to store the names and locations of all the available files, how does the Gnutella software on your machine find a song on someone else's machine? The process goes something like this: You type in the name of the song… Continue reading Gnutella Working

## B – Tree

B-Tree is a self-balancing search tree. In most of the other self-balancing search trees (like AVL and Red Black Trees), it is assumed that everything is in main memory. To understand use of B-Trees, we must think of huge amount of data that cannot fit in main memory. When the number of keys is high, the data is… Continue reading B – Tree

## Heap – Theory

For a binary heap we have O(log(n)) for insert, O(log(n)) for delete min and heap construction can be done in O(n). SO Searching in a heap - You need to search through every element in the heap in order to determine if an element is inside. One optimization is possible, though (we assume a max… Continue reading Heap – Theory

## BST – Set 1

BST Visualizer In a complete(almost) binary tree number of nodes (n) and height of tree (h) have a relationship like => n = 2^(h+1) -1, this is the all the nodes of the tree. If we have n nodes in a complete(almost) BT then height of the tree will be floor(log(n)), (base 2) this is… Continue reading BST – Set 1