-
Can the keys in Hashing data structure be made Mutable?
-
The answer is NO. If we make the keys mutable then the hashcode() of the key will no more be consistent over time which will cause lookup failure for that object from the data structure.
-
As bucket location is calculated based on key’s hashcode(), any change in key value will the change the hashCode calculation so is the problem in finding the stored object.
-
Never make changes to the hashmap’s key, otherwise the associated object can not be fetched using get() method.
-
Though it will be accessible using other methods which iterate over the entire collection.
-
-
Here are 1 million trades, you need to check if a given trade exists in those trades or not. Which Collection would you chose to store those 1 million trades and why?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Sample algorithms logic reference | |
Array: | |
* Write a function rotate(ar[], d, n) that rotates arr[] of size n by d elements. | |
code snippet: | |
void leftRotate(int arr[], int d, int n) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* What's the distributed system ? | |
** It's a system that's spread over more than location. | |
* why distributed system ? | |
** The purpose of distributed system, or dividing it over more than one physical location, | |
is to fix the machine and organisational perfomance problem by using two powerful operational and architectual concepts: | |
*data copying and decoupling* | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
What's lambda expression ? | |
* Lambda experession is java's way introducing functional programming into the language. | |
* Lambda removes the bulkiness inner class with more compact solution. | |
This simple horizontal solution solves the "vertical problem" presented by inner classes. | |
* Lambdas treat functionality as a method argument or code as data. | |
* Lambda works with functional interface i.e. an interface with single abstract method(SAM) | |
* Typical structure any lambda experession | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step 1 | |
Create an interface. | |
Shape.java | |
public interface Shape { | |
void draw(); | |
} | |
Step 2 | |
Create concrete classes implementing the same interface. |
Uncle Bob, the well known author of Clean Code, is coming back to us with a new book called Clean Architecture which wants to take a larger view on how to create software.
Even if Clean Code is one of the major book around OOP and code design (mainly by presenting the SOLID principles), I was not totally impressed by the book.
Clean Architecture leaves me with the same feeling, even if it's pushing the development world to do better, has some good stories and present robust principles to build software.
The book is build around 34 chapters organised in chapters.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Below are the Big O performance of common functions of different Java Collections. | |
List | Add | Remove | Get | Contains | Next | Data Structure | |
---------------------|------|--------|------|----------|------|--------------- | |
ArrayList | O(1) | O(n) | O(1) | O(n) | O(1) | Array | |
LinkedList | O(1) | O(1) | O(n) | O(n) | O(1) | Linked List | |
CopyOnWriteArrayList | O(n) | O(n) | O(1) | O(n) | O(1) | Array | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Code | |
import React from 'react'; | |
import Chance from 'chance'; | |
class Detail extends React.Component { | |
render() { | |
return <p>Hello, {window.Chance.first()}!</p>; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Code | |
import React from 'react'; | |
import Chance from 'chance'; | |
class Detail extends React.Component { | |
render() { | |
return <p>Hello, {window.Chance.first()}!</p>; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.ArrayList; | |
import java.util.Arrays; | |
import java.util.HashMap; | |
import java.util.List; | |
import java.util.Map; | |
import java.util.PriorityQueue; | |
public class Dijkstras { | |
public static void main(String[] args) { |
NewerOlder