Menu bars

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Saturday, 8 August 2015

Core java interview preparations-Links

These are my notes on Core java while i was preparing for interviews. As you know core java holds an important percentage of questions in a technical interview. Here i am listing all the important portions of core java and corresponding links. The difficulty level is above average and i am not listing the basic topics. This will be helpful to you if you have basics of java and prepare for a technical interview or something.Lets start !

Before that if you want to have general reading about java concepts then read : Link & Link

Special case of long & double with volatile keyword - here

  • Thread vs process - here


  • How HashMap works ?
This is an important topic for technical interviews ,
         Click here 2
  • Executor framework
This link provides all the concurrent util methods of java.

Database interview Links

  • 10 Frequently asked SQL Query


ARP commands

ARP commands

sudo arp-scan -l --interface=wlan0

arp-scan sends ARP packets to hosts on the local network and displays any responses that are received. The network interface to use can be specified with the --interface option. If this option is not present, arp-scan will search the system interface list for the lowest numbered, configured up interface (excluding loopback). By default, the ARP packets are sent to the Ethernet broadcast address, ff:ff:ff:ff:ff:ff, but that can be changed with the --destaddr option.

it is used to find out what all are the hosts that is connected to the local network.Another way of finding out the same with “Ping” with nmap[ nmap -sP 192.168.0.1/24 ]


You can find details about the arp-scan from http://linux.die.net/man/1/arp-scan.
In the above command “ -l ” tells you to scan all local network and --interface tells to use which interface to use.

Quickly if you want to know about the other hosts,Use arp-cache by:


But my ARP-SCAN was not pulling out all the network hosts that are connected !!! Dont know know why ?? NEED MORE RESEARCH !!!

3 ways to find out all the hosts in the LAN :

  • nmap -sP 192.168.0.1/24 [ Works !! need to test against firewall ]
  • sudo arp-scan --interface=eth0 192.168.0.0/24 [ Errors !! not complete list]
  • arp -n [ Accessing already saved arp-cache !! may not be reliable]

Links::
Crack wifi password with aicrack :


Trie data structure




  • Trie is a multi-way search tree where each node represents each character and all the children of the same will be having a same prefix.
 


  • Rather than storing the character each node will be storing the prefix.
  • Structure of the Node :
                   String prefix;
Node[26] children;
Each node will hold an array of 26 nodes where each node represents the each    letter. If some letter is not present then that will be empty. It is an overhead of trie because it used extra memory which is not using.


  • Now we have to think about how to organize or store the array of nodes.
     
   Two possibilities are 1) Store as array
                                     2) Store as linked list


If you store as array we can access it in a indexed way,but we have to waste much memory.


if you store as linked list then access time of the search string will increase( search in linked list of 26 nodes is O(26) and we need to travel m levels where m is the length of search string, that sums to O(m*26)) but memory usage will be optimal.


But if we use HashMap then you can get the time complexity O(1) and memory also will be optimal O(n).

Shortest path algorithm

You might have searched for different routes between two locations in google maps, but have you ever  thought about how would they do this ? finding all those small junctions and even tracking traffic in real time. Sounds crazy !!


Computer Science will have answer to each and every question !! The above scenario can be done with graphs. Say we find all the junction in the map and put those in a graph vertex. now we need to find the shortest path between 2 nodes. We are Done !!. One more application of the same will be in networking finding the shortest path to reach from one computer to another.




In the above image if i want to travel from “u” to “z” then what will be the shortest path ??
u + x + y + z will cause only 3 , if you see all the other paths will be causing more cost.
But what if there  1000 nodes we cannot count it and find which is the best path available. So we have to come up with some algorithm to do this.


There are many algorithms doing the same :


  • Dijkstra’s algorithm
  • Bellman-ford algorithm
  • Floyd Algorithm.

Dynamic Programming


It is considered as a careful bruteforce. And interestingly we will get it in polynomial time.What it does is divide the problem into sub problem and solve the same and reuse the same for larger problem.
Lets take the example of fibonacci number !!

F(n) :
if(n <= 2) :
     f = 1;
else :
     f =  f(n-1)+f(n-2);
return f;

Looks like neat !! But it is not because it running in an exponential time, because each time recalculating many functions.

Eg : F(4) :
f = [ F(3) + F(2) ]
 = [ F(2) + F(1) ] + 1
 = [ 1 + 1 ] + 1
 = 2 +1
 = 3
Here we can see that F[2] is calculated 2 times. Like that there may be many situations where we are recalculating.

Proof exponential time :

T(n) = T(n-1) + T(n-2)+ O(1)
      > 2T(n-2)
          = O(2^(n/2))

Get started with Drupal Installation in Ubuntu 14.04

Introduction


Drupal is a robust Content Management System that is available in the market. This uses  LAMP server and which includes MySQL and  Apache.It can host blogs, forums, and a variety of other content. It has a huge selection of modules for other functionality, such as advertising, chatbox etc. Even though there are many other CMS are available in the market, still Drupal stands out with its flexibility to adapt to any requirements. If you want to use Drupal then you have to have basic web development knowledge.  Wordpress and Joomla limits to you to stick to their standards but drupal give you the flexibility to design the blog or website as your wish.
Lets check how to install Drupal on a ubuntu 14.04 machine.

Step 1: Install LAMP server

LAMP contains Linux, Apache, Mysql, php. We need to install LAMP before we install Drupal.
sudo tasksel install lamp-server
Install tasksel if it is not installed already,
sudo apt-get install tasksel