Saravana Kumar's

What matters

Union-Find Data Structure Python : For Clustering Algorithm

| Comments

I was coding kurskal’s clustering algorithm for a max-spacing k-clustering problem. To improve the efficiency of the clustering algorithm, I needed an efficient data structure to union two cluster and find an element in a cluster.

Union Find (disjoint-set) data structure is best option for above operations. Implemented the Union Find structure as per the algorithm specified in the Introduction to Algorithms book.

This Implementation includes Union by Rank and Path compression, which gives a amortized runtime of a(n) (i.e a – Ackermann function)

Interview Street Challenge - Candies


Problem:
         Interview Street Problem:

Idea:
        If the rating is in increasing order
                             - Just traverse through it and increase the number of candies
        If the rating is in decreasing order
                             - Same as increasing order but in reverse way
        If the rating is in random
                             - the ordering will be like line of mountains with valley in between.Refer to this

Solution:
C++ solution in git
Passed all test cases.

Serial Port Communication in Windows Using Java

Serial Port communication using java can be done using RXTX library.  RXTX library is a native library provides serial and parallel communication for the Java Development Toolkit (JDK). RXTX is provided under gnu LGPL license. RXTX provides same support as javax.comm library

Installing RXTX in Windows 32Bit Machine:

  • Identify your Java Runtime Environment’s folder. For version 1.6.0, this usually isc:\Program Files\Java\jre1.6.0_01\

  • Copy the files from the downloaded RXTX binaries folder. Download binaries here http://rxtx.qbang.org/wiki/index.php/Download

  • Copy rxtxParallel.dll to c:\Program Files\Java\jre1.6.0_01\bin\

  • Copy rxtxSerial.dll to c:\Program Files\Java\jre1.6.0_01\bin\

  • Copy RXTXcomm.jar to c:\Program Files\Java\jre1.6.0_01\lib\ext\

Installing RXTX in Windows 64Bit Machine:

Do the same as for 32 bit except download the binaries from here http://www.cloudhopper.com/opensource/rxtx/

Using RXTX in Eclipse

Usually RXTX works but for eclipse sometimes it won’t work. You can use below way to configure the eclipse environment.

Way-I:

  • Copy RXTXcomm.jar, rxtxSerial.dll and rxtxParallel.dll files to the lib directory of your project
  • Under Project | Properties | Java Build Path | Libraries
  • Click Add JARs… Button
  • Select the RXTXComm.jar from lib directory
  • Jar should now be in the Build Path
  • expand the RXTXComm.jar entry in the list and select “Native Library Location”
  • Select the project lib directory and apply

Alternative way:

The above setup didn’t quite work for me, so here is an alternative.

  • Copy RXTXcomm.jar to the lib directory of your project.
  • Navigate your package explorer to the lib folder, right click on RXTXcomm.jar | Build Path | Add to build path.
  • Copy rxtxSerial.dll and rxtxParallel.dll files to the root directory of your project.
  • Under Run | Run configurations | Classpath tab | User entries | Advanced | Add folder, choose the root folder of your project.

This should be enough just to run it under Eclipse, when deploying a runnable jar, just make sure the dlls are on the same folder as the jar (JVM assumes it for classpath).

For installing RXTX in Other OS:

Refer this link http://rxtx.qbang.org/wiki/index.php/Installation.

Usage:

import gnu.io.*;

The above header file is equivalent to javax.comm and provides all classes and methods provided by it.

Be careful when using System.in.read() and rxtx in win32; 
It can trip across a known JRE deadlock bug.

Samples:

Follow below link for samples given by rxtx. Link

Answer to a Question(Numeric to Word)

Read a interview question to write an algorithm to convert entered numeric values to words (ex: 1—one ,2 – two) for up to six digits. Is it hard to convert ? No . We could do this in lot many ways but an effective program which uses proper data structure and algorithm that’s what it takes.

Here I got it https://sites.google.com/site/ourorganisationsite/number-to-currency

I had a dictionary to hold one and Tenths position words then rest lies in identifying the position of a numeric.

One of friend surpassed my limitation and he converted number till Quintillion I dont have idea how many digit has ? Awesome work chinmoy!!!

MVC Architecture

| Comments

The power of MVC Architecture in ASP.Net:

  • Great level of modularity .Abstraction between layers and functionalities too.
  • Your Html code will be neat ,no more unwanted scripts and ugly ids for controls (i.e.) “ctl_100contentplaceholder_input”.
  • Easy accessable of control ids from java script .
  • Easy integration with jquery and other ajax frameworks .
  • With LINQ and SQL class, database is abstracted totally from the other business logic.
  • Clean Urls ,Mapping of urls are done nicely as in servelts (Java) .
These are some of the advantages I explored so far .

Working on it ..Will update if get to known more..

Comments

SEO,SEM
ya started blogging it seems……….






http://kpsnirmalsingh.wetpaint.com/
http://nirmalsinghkps.wordpress.com/
Montu
gethu man !