Thursday, September 16, 2010

Curd Semi Sambar

I thought of sharing a different recipe in Sambar. Well, lets see if it is any good different.

Curd Semi Sambar (for 2 persons)

Ingredients needed

  • mustard 1 spoon
  • cooking oil couple of spoons (as you like)
  • 5-10 leaves of curry leaves & equal amount of coriander leaves chopped
  • 1 green chilly
  • 2 spoons of chana dal (Kadalai Paruppu)
  • 1 spoon of Turmeric powder
  • 2 spoons of coriander powder
  • 1 spoon of red chilly powder
  • 1 onion cut in small pieces
  • 4-5 medium size tomatos (cut in small pieces)
  • 1 big radish (cut in small pieces) or any other vegetable suitable for sambar
  • 1/2 cup curd (keep it as lesser as possible)
  • salt 1 or 2 spoons to the taste


Procedure

Frying:
Start with the dry hot Kadai (open vessel used for sambar) and pour the cooking oil. Let it heat up a bit and put the mustard to wait till it pops. Immediately add the chana dal and cross cut green chilly pieces, and fry it till the dal becomes golden brown (one can fry the dal separately and use it now as well).

Add curry leaves and coriander leaves and mix a bit. Now, you can add onion and fry it for couple of minutes, then tomato and fry it till it weakens; and then add the radish followed immediately by turmeric powder, coriander powder, chilly powder and salt. You got to fry the whole mix till radish absorbs all the masala and gets semi cooked. Now is the time to move to boiling the thing with water.


Boiling:

Just before you pour the water, add the curd and mix for 5 seconds and pour water sharply before the curd turns into milk residues. Pour water till the veggies immerse. Now taste for hotness of chilly and salt. Add chilly powder or salt till it tastes good. One can vary the amount of curd to his style. The more curd you add, the more it becomes "more kulambu" so don't add too much curd.

Now let the Curd-Semi-Sambar boil till radish gets cooked properly.

It's called semi sambar because we don't use toor dal.

Now it is ready to be served with boiled rice hot and tasty.

Enjoy!


Wednesday, July 21, 2010

Boredom

Aah.... Again I was munching on some dumb philosophy....

This is how it started.....

Recently my friend was saying, he is completely bored and boredom is killing him....

Well, I quickly noticed that he is not the kind of person who says he is bored that easily.... Well something really is wrong....

But I don't know clearly what it was..... only fact that lingered in my mind is, he is forcing the boredom on himself...

I used to get bored a lot of time... not new for me... in fact, the only thing we would feel when we are bored is that 'we are bored'....

I know how it would feel.... like I do not want to do anything and that makes the time dull and slow and I would hate it, and that would make me so unenergized and that will cause more of non-activity and boredom increases rapidly to a new level...

Somewhere at a tricky little shadowed corner of our mind we knew that boredom is not something that is outside of us though we always talk about it as an external thing....

Boredom is not forced on us by outside force or factor.

It is a resolve to not indulge in anything causes the disease called boredom.

This was so clear to me when my friend experienced this disease than the time I experienced it.

So I had to create a quote 'Boredom is simply a refusal to engage in anything'.

And I had to write an entire blog also, not because I'm bored but to record my idea ;)

Friday, May 7, 2010

A good Tamil online dictionary

Recently I wrote few poems in Tamil. Since, for the past 10 years I was not in touch with Tamil much due to Engineering and my Occupation, I really forgot few basics in Tamil which I was dead clear until my 12th standard.

Like, which RA should come in உரையாடல்.

Really really I should be ashamed but, anything can be forgotten which is the human curse.

I didn't know where to check in online about such doubts.

Also, any English-Tamil dictionary will not have standard English words like 'squat'. And so many high profiled words are not available in any dictionary. I used to use a SriLankan online site which gives meaning in Tamil/Singala for most nominal English words.

But there is a new smart kid in the block for my problems. It gives Tamil meaning for even most complex English words (I mean a lot greater better than any I have been using so far).

It also helps me confirm my Tamil vallinam/mellinam issues in my poems.

Well, the kid was born in Anna University, Madras Institute of Technology, AU-KBC Research Center.

Here he is >>> http://searchko.in

Sunday, March 7, 2010

மனைவியின் கர்ப்பம் [Wife's Pregnancy]

சிறுகதை [A short story]

சிறு பிள்ளையின் மனதை விட மறுக்கும் அந்த இளைஞ்சன் கார்த்திக்.
[Karthik, a young man, still not ready to shed his boyish behaviour.]

அன்று அவன் மனம் இனம் புரியாத நெகிழ்ச்சியில் மிதந்து கொண்டிருந்தது.
[That day, he was unusually elated.]

நிலவு போல் பால் வடியும் தன் மனைவியின் முகத்தை பார்த்தான்.
[He looked at his wife whose face shone like a full moon.]

அவளின் கண்கள் கார்த்திக்கை நோக்கின. "நீதான் என் உலகம்...." என்றன.
[Her eyes set upon karthik; her look said "You are my world....".]

கார்த்திக், இப்பிறப்பில் அவன் கொண்டு வந்திருந்த அத்தனை அன்பையும், தன் மனைவிக்கே கொடுத்திருந்தான்.
[Karthik has showered the whole of his love from his entire life, on his wife.]

அது அவளுக்கு தெரியும். அவர்கள் இருவரும் ஒன்றுக்குள் ஒன்று.
[She knows it. They blended with each other.]

அவன் அவளின் கைகள் இரண்டையும் பற்றிக்கொண்டான்.
[He took her hands in his own.]

அவளின் மெலிந்த விரல்களை வருடி, தன் இதழ் பதித்தான்.
[He gently kissed her long soft fingers.]

அவளை மெதுவாக அழைத்துச்சென்று, மெத்தையில் அமர்த்தினான்.
[He slowly guided her, and made her sit on the bed.]

அவள் 9 மாத கர்ப்பிணி. தன் தாய் வீட்டிலிருந்தாள்.
[She is in 9 month of her pregnancy. She is at her father's.]

அவன் ஊரிலிருந்து, அவளை பார்க்க வந்திருந்தான். வீட்டில் யாருமில்லை தற்போது.
[He has come to visit her. No one at home now, except themselves.]

அழகான தன் மனைவியின் வயிறு, அளவுக்கு மீறி வளர்ந்திருந்தது.
[Her belly has grown a lot.]

பூசணிக்காய் கோபப்பட்டு, பெரிதாகிவிட்டது போல.
[It's like a water melon vengefully grown out of bounds.]

கார்த்திக், அவள் அருகில் அமர்ந்து அவள் வயிற்றைத் தொட்டுப்பார்த்துக்கொண்டான்.
[Karthik sat close to her and touched her big belly.]

அவள் கணிவோடு அவனைப்பார்த்தாள்.
[She looked at him fondly.]

அவன் லேசாக புன்னகைத்துவிட்டு, அவள் வயிற்றில் தன் காதை வைத்து உள்ளிருக்கும் தன் மகனின் ஓசையை கேட்டான்.
[He smiled shyly and placed his ears on her belly and listened to the sounds of his son inside.]

"இன்னும் ஒரு மாதம் பொறுத்துக்கொள் செல்லம். உனக்காக நான் செய்த பரிசை கொடுத்துவிடுகிறேன்" கிசுகிசுத்தாள் அவள் அவன் காதில்.
[She spoke in his ears, "Wait for another month darling, I will give you the present I made for you."]

"பிறகு, நீ என்ன தருவாய் எனக்கு?" என்றாள் அவள்.
["What will you give me in return?" she said.]

நான் உனக்கு..... இன்னொன்று தருகிறேன், என்றான் சிரித்துக்கொண்டே....
["I will give you....... another one?" He said with a little laugh.]

"அடப்பாவி......!" என்றாள் பொய்க்கோபமும், வெட்கமும் பிடுங்கி திண்ண.....
["You....!" she faked an anger shy-fully.]

கார்த்திக் தன் போர்வைக்குள் சிரித்துக்கொண்டான். இன்னும் எழ மனமில்லாமல், தனக்கு வரப்போகும் மனைவியைப் பற்றி கனவு காண, மீண்டும் புரண்டு படுத்தான்.
[Karthik shifted in his blankets. Still not ready to get up, he turned to other side to continue dreaming about his future wife.]

Saturday, March 6, 2010

Interviews: Core Java, Swing, NMS, EMS, GWT and Puzzles

Interview Questions (Top search results on Google):

Articles:
  1. http://java.sun.com/docs/books/tutorial/essential/exceptions/
  2. http://java.sun.com/javase/technologies/core/basic/serializationFAQ.jsp
  3. http://java.sun.com/developer/technicalArticles/Programming/Stacktrace/
  4. http://www.javaperformancetuning.com/news/qotm026.shtml (garbage collection alg)
  5. http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html
  6. http://www.ibm.com/developerworks/rational/library/content/RationalEdge/sep04/bell/ (UML class diagram basics)
  7. http://java.sun.com/docs/books/tutorial/essential/index.html (Essential classes of JDK)
  8. http://java.sun.com/docs/books/tutorial/collections/index.html (Collections tutorial)
  9. http://java.sun.com/developer/technicalArticles/Programming/serialization/ (Serialization and Externalization)

Go through java related sites like JavaWorld, JavaLobby, etc. and prepare on JVM Internals, threading internals, collection framework in depth and design.

Topic Set 1:

From Cisco,

Java Basics:
1. Usual questions in java collections , Thread and Exception handling
2. JDK tools
3. Java Monitoring and profiling, debugging tools and techniques
4. Customizing class loaders and find out the ClassLoader of a specific class
5. Serialization : Externalizable Vs Serializable and Versioning. Some scenarios

Threads:
Some scenario discussion to find out deadlock, same as Producer Consumer problem but with some differences.
1. How does Thread lock work?
2. How to create Threads using Java, what is the difference
3. Discussion on wait() and notify(), notifyAll()
4. Why wait() and notify() have to be within synchronized block

Real time problem discussion : Designing
1. Design a Security Manager that authenticates a system using username and password

SNMP
1. SNMP – getBulk() Vs getNext()
2. How SNMP index works
3. SNMP V1 vs V2 vs V3 at PDU level and functional level
4. SNMP message processing subsystem for V3

Programs :
1. To find out the SQRT of a given number
2. To find whether a given number is a Power of two or not
3. Program to convert a Doubly Linked List with N elements to N Singly Linked List. This is to be discussed at design level

Topic Set 2:
1. UML Patterns

a. Draw a UML diagram expressing the relations between various Managed Elements in NMS.
b. Various UML symbols and their meaning

2. NMS/EMS questions

>Define NMS and EMS
>Explain FCAPS
>Where snmp traps fit in FCAPS?
>Difference between snmp-get and snmp-get-bulk commands
>Difference between snmpv2 and snmpv3 message format?
>When would I call a trap as an inform request?
>What would you do if trap processing thread pool is overloaded?
>what is alarm-correlation?
>what happens in NMS when a trap is received? (explain till event gets propagated to GUI)
>how snmpv1 and snmpv2 differ in PDU format?
>how would you get the index/id/oid of a table when the table oid itself is not a valid oid, but its children are?
>advantages/disadvantages of getnext and getbulk, when used, to query a table?
>In which protocol layer, the acknowledgement to inform request is issued(DataLink/IP/Transport/Application)?
>When you receive clear trap for a failure whose trap you never received, what actions will you take? should it be processed at all?
>Format of getBulk request?
>how do you form getnext request? what goes in there?


3. Core Java

a. What is the need/purpose for the existence of Exception concept in java?
b. How would you define your own Checked Exception?
c. What do you know about Exception escalation among different layers of a java application?
d. Garbage collector algorithms (if you don't know the algorithm, then design an algorithm/methodology for garbage collection - i said don't know and i was asked to design a new one, so better know some basics in garbage collection algorithms to design a new one)
e. Serialization
f. Java Patterns and write a program explaining factory pattern
g. Write singleton pattern program (aware of all the loopholes in that simple singleton program)


4. Threads

a. what is a thread?
b. write a program to demonstrate thread communication in java
c. working mechanism of wait(), notify() and notifyAll() methods
d. role of synchornization in thread communications and understanding of class or instance level synchronization
e. differences in method-level and block-level synchorization
f. why do we need threads?
g. Thread Pool and Working Threads (i didn't know this... so they stopped this topic)


5. General questions

a. how would you handle the situation when you didn't properly complete a development and your manager asks you to deliver it immediately without knowing that you didn't do the work satisfactorily?
b. how would you start your work every day?
c. how would you handle a friend-cum-teammate who does unethical thing in work?

You will get J2EE questions if have put any in your resume. I said i didn't know about J2EE at all. So, they didn't ask. But our project uses J2EE server. So, they'll definitely ask this.

Topic Set 3:
Java
- producer consumer problem/ wait(), notify(), join() and synchronization
- gc and its implementation, design a garbage collector, can we force garbage collection?
- What factor determines the start of garbage collection.
- cloning hashtable (if object-stream, is it efficient?)
- Avoiding memory leaks
- how to go about doing profiling
- runtime polymorphism sample (B b = new B(); A a = (A) b; a.f1(); what's the o/p if f1() is overridden by child class B?)
- diff between inheritance(extending) and interface
- thread pool
- Exceptions: can we define our own RuntimeException? Differentiate checked and runtime exception.

write code throwing an exception... why should throw an exception instead of returning an error code?

why do we need exceptions at all?
- design patterns (singleton and factory)

NMS
- diff snmpv2 and snmpv3
- snmp bulk request
- difference between snmpget and snmpbulkget.


Project
- Block diagram of the project upto the end-device
- satisfying work/moments in your project/experience

Question: What is similarities/difference between an Abstract class and Interface?
Answer: Differences are as follows:
· Interfaces provide a form of multiple inheritance. A class can extend only one other class.
· Interfaces are limited to public methods and constants with no implementation. Abstract classes can have a partial implementation, protected parts, static methods, etc.
· A Class may implement several interfaces. But in case of abstract class, a class may extend only one abstract class.
· Interfaces are slow as it requires extra indirection to find corresponding method in in the actual class. Abstract classes are fast.

SNMP Stuff
The following list shows the differences between SNMP from V1 to V3.
SNMP V1
SNMP V2
SNMP V3
Get-Request
Get-Request
(The basic functions of V3 are from V1 and V2)
Get-Next-Request
Get-Bulk-Request
New SNMP message format
Set Request
Get-Next-Request
Security for message and Access Control
Get Response
Set Request

SNMP v1 Trap
Inform-Response


SNMP v2 Trap


Report



Misc
  1. XML parsers in java [DOM and SAX]
  2. Tomcat(called apache tomcat) and Apache(called apache webserver) are different? Yes. Tomcat is pure java implementation and provides tools for configuration and management. But apache is C implementation with no tools.
a. public class ThreadRecursion {
b.
c. public static void staticMethod()
d. {
e. System.out.println("Inside static method...");
f. ThreadRecursion tr = new ThreadRecursion();
g. tr.normalMethod();
h. }
i.
j. public void normalMethod()
k. {
l. System.out.println("Normal method...");
m. ThreadRecursion.staticMethod();
n. }
o. /**
p. * @param args
q. */
r. public static void main(String[] args) {
s. ThreadRecursion tr = new ThreadRecursion();
t. //any of the following calls lead to stack overflow; no issues for the main thread to acquire the lock
u. tr.normalMethod();//main thread calling instance synchronized method
v. ThreadRecursion.staticMethod();//main thread calling static synchronized method
w. }
x.
y. }
  1. How to detect a loop in a one-way-linked list?
  2. Nested classes: 1. Static nested classes, 2. Non-static nested classes are also called inner classes
  3. Default Annotations are SuppressWarning, Override (detects wrong overrides) and Depricated
  4. writeObject() readObject() for serialization are private methods. JVM can call this private methods. Using reflection you can call private methods (methodObj.setAccessible(true))
  5. serialver tool is used to create serialVersionUID (this is done for serialized objects)
  6. Thrown NullPointerException need not be caught at compile time. At any situation RuntimeExceptions will not be complained by Compiler (either the throws clause or throw caluse)
  7. When you write large amount of objects into ObjectOutputStream, OutOfMemoryError is thrown, why? Because, ObjectOutputStream caches all the objects written into it and these copies are not cleared though all the objects are not being used by the application
  8. Why Object is not Serializable() and Cloneable()? Because of security reasons. Anyone can clone or serialize and send it across the network or into a file. This opens up all the private data members as well.
  9. How to implement a Queue using two Stacks? (NetApp)
  10. Static members will not be serialized.
  11. ReadResolve() and WriteReplace() are found in serialization context when you need to designate alternate Object to be used for serialization.
  12. When serialVersionUID doesn’t match, serialization throws exception
  13. System.gc() and Runtime.gc() are the same. System.gc() calls Runtime.gc() internally.
  14. Volatile variables are not in-lined(replaced by actual values done by compiler as optimization strategy). Normal instance variables are in-lined(copies) and in a multi-threaded environment, this could lead to wrong value. So, declaring such members as volatile is a must to avoid compiler optimization in multi-threaded environment.
  15. Java is completely pass-by-value. The object references passed to a method are actually a new copy of the passed object reference. That is same reference (as with c++ pointers) is not carried through method call hierarchy.
  16. Uncaught exception is caught and displayed by “main” thread. Before “main” thread is terminated it calls the UncaughtExceptionHandler which is “system” ThreadGroup in this case and after executing the uncaughtException() method it terminates.
  17. JVM has 4 daemon system threads. [Reference Handler, Signal Dispatcher, Finalizer, Attach Listener] whose priority respectively [10,9,8,5]. The priority of main thread is 5.
  18. When a new thread is spawned it gets the priority of parent thread.
  19. The default UncaughtExceptionHandler for main thread is “system” ThreadGroup.
  20. Defining immutable object: http://java.sun.com/docs/books/tutorial/essential/concurrency/imstrat.html
  21. String immutable topic
Swing
  1. UI Manager
  2. Swing MVC is more accurately called Model-Delegate (controller and view combined together into UI delegate)
  3. Thread safe methods in swing are repaint(), revalidate() and invalidate()
  4. UI delegate is derived from abstract class ComponentUI
Nomura
  1. Which thread the listeners run on? Event Dispatcher
  2. Which thread invokeLater() call will run on? Event Dispatcher
  3. Will main thread terminate when a swing application is run but frame is not closed? Main thread terminates. Only EDT Event Dispatcher Thread lives.
  4. Will Model intimate the UI for changes and how? Yes.
  5. To insert a column in a table dynamically, where should we change? On DataModel or ColumnModel? In ColumnModel.
  6. How a thread other than EventDispatcher thread, can update a GUI? It can’t except for the thread safe methods, invalidate(), revalidate() and repaint()
  7. Can I use paint() method to refresh my component? Just a component yes. Even repaint() calls paint() on the components.
  8. What is the difference between repaint() and paint()
  9. What is the difference between revalidate(), repaint() and invalidate()
  10. Class Loaders?
  11. Where did you use reflection?
  12. What is the access modifier of clone() method
  13. In which class readObject() and writeObject() methods are located?
  14. In which class clone() method is located?
  15. Which one is efficient to make a copy of an object, Cloning? Or, Serialization/deserialization?
NetApp (see GWT section on GWT questions)
  1. Multiple huge files (thousands of GBs) are there. Reverse the letters in each word and create a new file. Design your application to do efficient copying. [Using stack to reverse the characters in the words; and threads to read, write and reverse letters so that you can make it faster]
  2. Write a class to make a growable array without using any collections framework classes
  3. How can you make a non-serializable third party class to serializable in your application? (one object handing over to another object to serialize/deserialize, externalization?)
  4. Why do we need JSON when XML is available? (XML is fatty with repeating tag names)
  5. There is a thread which is allowed to crash (you should restart it) 5 times within an hour. In this case, the thread will be restarted. If it exceeds 5 within an 1 hour time frame, exit the system. Design this system.
  6. You have 1 million data at server. You can’t show everything in client. How do you pull this large amount of data using dynamic data pulling?
Questions sites:-
  1. http://www.techinterviews.com/java-swing-interview-questions
  2. http://www.javacertificate.net/swing_qns.htm
  3. http://www.interview-questions-java.com/java-swings.htm
Data structures and algorithms
http://www.javaworld.com/javaworld/jw-05-2003/jw-0502-java101.html
Global scholars, RedKnee and Firetide
  • Write a class to implement a growing array without using available collection framework [I used an object array with fixed size and periodically increasing it's size as it grows by copying it to a bigger array]
  • Write a Node class to implement a node in a linked list. Then write a method to reverse list (one way linked list) which takes rootNode as argument and returns new root node.
  • How would you find 3 biggest numbers in a given array without using Collections framework?
  • How would you find the 2nd biggest number in a given array without using Collections framework (similar to above)?
  • How would you find the 3 numbers which will give biggest product (a*b*c)? The array can have zero, positive and negative numbers. Without using collections framework.
  • How can you achieve pass-by-reference for primitive arguments in java? (I didn't answer this question)
  • How can you bit reverse a given number for a given processor (32bit or 64bit)? Write a program in java. (I only wrote partial answer as pseudo code; which involves plucking one bit by bit from the given number by doing AND with 1 and doing right shift continuously. As you pluck bit by bit, construct a new number by left shift)
  • Can you call obj.x (where x is a private member of the class) inside the same class? I said no, but he said yes, it is possible in java.
  • In the following program, where compilation will fail and why?

class A {}

class B extends A {

public static void main(String[] args)
{
A obj1 = new A();
B obj2 = new B();
A obj3 = new B();
B obj4 = new A();
B obj5 = obj3;
}
}
  • Write equals method override version for an object which has a string and integer data members. This object needs to be used as key in a hashmap.
  • What JVM parameter will you use to tune garbage collection?
DESIGN PATTERNS
I. Creational Patterns - How objects are created
1. Factory Pattern - Creates different class objects based on the input
2. Abstract Factory Pattern - Creates different factory classes based on the input
3. Builder Pattern - Creates a complex object composition. Not just instantiation of one object
4. Prototype Pattern - Builds a complex object once and then copies it or clones it whenever a new object needs to be created
5. Singleton Pattern - Only one object of a particular class is maintained
II. Structural patterns - How to compose or structure objects
1. Adapter Pattern - Translates one interface to another
2. Bridge Pattern - Decouples interface and its implementation so that both can be varied without the need to recompile the other
3. Composite Pattern - Composition of multiple objects
4. Decorator Pattern - Moves the custom behaviour outside of the class so that multiple behaviours can be imposed on the same class as needed
5. Facade Pattern - Simplifies interfacing with a complex system, by providing single point of contact for all API invocations
6. Flyweight Pattern - Multiple objects store common data outside of themselves in a common place
7. Proxy Pattern - defers copying of some data of an object till it is necessary
III. Behavioral patterns - How objects communicate1. Chain of Resposibility Pattern - Event is passed among multiple parties until it reaches the right party who can take some action
2. Command Pattern - Defined commands invoke particular action on the other side
3. Interpreter Pattern - A syntax interpreter for a new protocol
4. Iterator Pattern - How to move through a list
5. Mediator Pattern - Decoupling the communication dependency between two objects and placing it in a mediator object
6. Momento Pattern - Persisting an object regardless of its functional or behavioural aspect
7. Observer Pattern - How changes on one object can be intimated to others
8. State Pattern - Different contained objects are used to provide memory for data members of container class thus dynamically changing the object behaviour
9. The Strategy Pattern - Provides algorithm in a class
10. The Template - Providing abstraction which would allow customization later. Inheritance is a template pattern.
11. The Visitor - The Visitor pattern adds function to a class so that it can visit later as part of iteration
Synchronization
Note that constructors cannot be synchronized — using the synchronized keyword with a constructor is a syntax error. Synchronizing constructors doesn't make sense, because only the thread that creates an object should have access to it while it is being constructed.
Warning: When constructing an object that will be shared between threads, be very careful that a reference to the object does not "leak" prematurely. For example, suppose you want to maintain a List called instances containing every instance of class. You might be tempted to add the line
instances.add(this);
to your constructor. But then other threads can use instances to access the object before construction of the object is complete. [Just know that while you modify your critical data inside the constructor, the other threads might start using this object and can modify your critical data parallel to the constructor. But still synchronized code is not allowed to multiple threads though the object is being constructed still.]
RMI
  1. With versions prior to Java Platform, Standard Edition 5.0, an additional step was required to build stub classes, by using the rmic compiler. However, this step is no longer necessary.
  2. the ability to download code dynamically, is often called a behavior-based application.
  3. RMI classes are made network accessible through webserver to download class definitions dynamically
  4. Write an RMI server client program.
Design Questions
  1. There is a web server which receives too many web requests and currently not able to scale. To make it efficient without using distributed architecture (other servers), what are all the things will you consider to improve the performance and scalability?
  2. There is a string in a file. Read it from the file and reverse the words in that string (keeping the words intact) without using another data structure. Splitting the string with space as delimiter creates one extra array of tokens. Provide some other way without using extra data structures other than the final resulting string or array. (do not use utility methods to reverse). Also do a complete reverse (character by character) of the string.
  3. There is an unsorted array of integers of length N. It contains unique numbers from 1 to N+1. Find the missing number. One simplest way is find sum S of all elements in the array. Then calculate Q = P * (P + 1) / 2 where P equals to N+1. Find the difference that is (Q - S) which will give you the missing number. If you can arrive at any other way, please do.
  4. There is an unsorted array of integers of length N. It contains unique numbers from 1 to N. But, only one number is occurring twice. Find that repeating number. Because one number is repeating and it is not a sorted array, the second occurrence of the repeating number can replace any number between 1 to N. So, the above formula cannot be used. I was not able to arrive at any efficient method to find the repeating number.
  5. How will you implement an LRU Cache (Least Recently Used items discarded in the Cache first) using Linked List? That is least recently accessed elements should be at one end of the linked list. Solution is to add new elements at the top of the list, and whenever someone reads any other element, remove it from there at put it at the top of the list. This would give most recently used elements at the top. Now, you can read from the end of the list to fetch least recently used elements. Or to delete least recently used elements, you can start deleting from the end of the list when cache overflows.
  6. How do you implement priority queue?
  7. The main method looks as shown below. What will happen to the new thread started? Will it be killed or interrupted?

{ Thread t = new Thread(); t.start(); t = null; }
  1. There are large numbers of English words to be stored. All words are unique. Anyone can add new words to the data structure. And also, you should be able to return any requested word, or words starting with given substring (like all words starting with 'hell' would be 'hell', 'hello', 'hells', or any junk words added earlier as well; need not be proper English words.). Design an efficient data structure for this requirement. I used alphabetically sorted tree to achieve this. Where partial strings will be as parent nodes, and full words will be leaf nodes. While inserting a new word say, 'hello', you need to pick up the tree starting with 'h', then go to 'he' child, then to 'hel' child, then to 'hell', then to 'hello' node and then add a leaf node called 'hello'. While some one searching for all words starting with 'hel', then go to 'hel' node and collect all leaf nodes under it and then return.
  2. There is a binary tree which can be unbalanced. That is left side of the tree might contain more elements than right hand side or vice-versa. Store this binary tree in an array in such a way that you should be able to reconstruct the binary tree later. The best solution I could arrive at is, find the capacity of the binary tree, that is based on the depth (number of levels in the tree), maximum number of elements that can exist (right hand side and left hand side of the tree are equal and full), though the actual number of nodes of the tree is lesser; take this as array length; put the root node in the middle of the array. Then recursively place left side tree in the left side portion of the array and also right side tree on the right hand side of the array. The array cannot overflow, because its length is based on maximum capacity of the binary tree.
  3. There is a question paper. This can have any type of questions. Do a modelling for this question paper so that you have a system to store this question paper into a data base and also easy to print the paper, or to evaluate the answer extra. Guidelines: List the parameters of any question paper you should consider. Then, arrive at interfaces and classes for your data structure. Then arrive at, database table design. Also, at last consider that the question paper also has match the following (one left option can match to multiple right side options) type of questions. [I said, type of the question like choose the answer, fill in the blank, provide your own answer, etc. Then, this decides question type, section under which questions are coming; then weight that is mark for each question. Data structure should be able to store multiple options of each question. How many number of blanks are there in fill in the blanks. Also, Question class should be able to accept relevant answers and validate or throw exception when wrong answer is fed. That is giving fill in the blank answers for multiple choice question. Then evaluation of the question. Then Question DB table with unique ID for each question. Then Options table with all the options per row, also having question ID as one of the column to indicate to which question this option belongs to. For fill in the blanks, having one blank option for each blank. Then, at last for match the following question, use separate table for left options and separate table for right options with question id as another column. When you need to match, you can match left side option with multiple right side options.
  4. There are two strings S1 & S2 as character arrays. Find all the common sub strings occurring in these two strings even the repeating sub strings. I after some time, arrived at sliding mechanism. Take the shortest string and position below the bigger string as though they appear to be character sliders. That is first character of big string is exactly above the last character of small string. Slide, one character at a time and try to find the common string until the first character of the small string reaches the last character of the longer string. The complexity would be (n1 + n2) loops where n1 and n2 are the lengths of these strings. Each loop is a search common string which would mark the start index position when same character occurs and mark the end index position when different characters occur. This would give the common sub strings.
Puzzles
  1. There are 3 boxes. One box contains all apples. One box contains all oranges. The last box contains mixture of Orange and Apples. But all these are wrongly labeled. Say A, O, AO like that. You can take one fruit from only one box without peeking inside it and see that fruit. Based on that, re-label the boxes correctly.
  2. There is a bridge which can be crossed by only two people maximum at a time with the help of a torch. There are four people with different speeds. One can cross the bridge in 1minute; one in 2 minutes; one in 5minutes and the other in 10minutes. How quickly these four people can cross the bridge. 19 minutes is easy to arrive. But they can cross in 17minutes. How?
  3. There are five jars containing equal number of pills of same kind and size. But, one jar contains full of defective pills whose weight is half of the proper pill. There are two scales. One is digital which will give exact weight if you put something on it. The other is balance scale which will show comparative weight. Left or right side will be lower. You can use only one of these two scales and that too only once. How will you find the jar which has defective pills. [ I was breaking my head with balance scale but couldn't arrive at any solution. Then he gave a clue that, it is possible to find this only with digital scale. ]
  4. Describe yourself in 5 sentences.
  5. 6 areas of weakness?
  6. Rate yourself in hard working in the scale of 1 to 10?
  7. Rate yourself in problem solving skill in the scale of 1 to 10?


GWT
  1. Automatic Resource Inclusion: The GWT compiler will bundle all the static resources required to run your application including the style sheets (images, etc). This mechanism is called Automatic Resource Inclusion.
  2. Deferred Binding: At runtime, GWT uses a mechanism called deferred binding to load the correct permutation for the end user's browser. Deferred binding serves just the code the user needs and no more. What are the benefits of deferred binding? Because each permutation is tailored to work around the bugs and idiosyncrasies of its intended web browser, using deferred binding is
· Faster, for the user.
Your application download contains no unnecessary bytes. The application doesn't need to sniff for browsers or provide multiple branches for each browser.
· Faster, for you.
GWT does the work of generating the correct JavaScript for each browser so that you don't have to spend so much time dealing with differences among browsers.
In addition browser detection, deferred binding can also generate customized versions of your application for any number of other variables. One very common example is internationalization. With deferred binding, GWT generates a separate implementation of the application for each language, so for example, an English speaker doesn't have to download the French text (and vice versa).
  1. Overlay types: Not only do you want to be access the array of JSON objects, but you want to be able to work with them as if they were Java objects while you're coding. GWT overlay types let you do this.
  2. How to handle history in GWT?
  3. What is the difference between directly creating an object and using GWT.create() method to create an object?
  4. Can we use same beans (data objects with setter and getter methods) in both server and client side in GWT?
  5. What is hosted mode?
  6. How to start your GWT module? (EntryPoint/onModuleLoad())
  7. How GWT handles sessions?

Thursday, February 18, 2010

The flip side of ganging up

I got a forward saying that 'Congratulations to all Indians'. It sort of rang a bell in my nasty mind somewhere.

In the name of being an Indian, we mostly never would've moved a slug (just an exaggeration to say, we did nothing). But, why do we be congratulated for being an Indian?

Of course you can feel proud about being Indian, and that may be considered as personal view.

But just for no efforts of our own, we identify ourselves as something. This is what I call as 'gang up'.

No no.... this is not new.... it comes from the time we originated....

We gang up based on several parameters...
  • Place (Same village, same street, same hotel, Chennaites, Bangalorians, northy, southy, etc)
  • Nationality (Indian, pakistani, jewish, african, etc)
  • Religion (Sikh, Hindu, Muslim, --->No offense, but this is just my observation; I think only Qatar airways is religion based<---)
  • Caste (Mostly during marriage)
  • Sex (We can understand this... boys gang and girls gang.... natural)
  • Profession ( Engineers and Managers gang up separately, and of course completely different field professionals gang up separately)
  • Knowledge on a particular subject (For example cricket followers will gang up against non-followers)
  • Nomenclature (of course, different breeds of animals gang up with their kind; a bunch of humans shooing an elephant herd, etc)
  • Relationship (Family, relatives, etc. My family and my uncle family never fit with each other, kind of....)
  • People Color (white , black, etc. Oi, don't think I don't know other colors and that's why I used 'etc'. There are yellow people if you remember!)
  • Food (vegetarian / non-vegetarian)
  • Sexual habit (better consult wiki ;))
  • Language/State (Malayalee, kannadiga, tamilian, gulti, punjabi, etc)
  • Romantic meter level (play boy, useless guy, etc)
Well, the point is, we normally tend to gang up in one way or another. In particular, we will be part of multiple gangs at the same time. Based on context and situation, the overlay of relevant gangs at that situation will give us what we are.

It is good to gang up because we feel at home in that gang. But the thing is, when you pose the existence of a gang by identifying a gang and becoming part of it, the existence of another gang is inevitable.

So what? You may ask. By nature, gangs are nothing but small piece of a big chunk differentiated by certain parameter. That means, the other chunk doesn't sympathize with this chunk. That's why we could differentiate them in the first place.

Coming to the core of the matter..... Because of this gang up, at different levels, we have conflict in this world in different sizes and shapes.

Political, geographical, regional, linguistic, philosophical, religious, and innumerable conflicts. Some religions in this world want to outgrow other religions. Some countries want to outgrow other countries. People in some economical section want to outgrow other sections. Some philosophers want to outgrow other philosophies. Some business want to outgrow other business.

Even in technology world, there are gang ups based on preferences. For example, Linux followers and Windows users. There is a gang of people who use Firefox and others who use default browser.

When the whole world moved to Gmail, only Americans stayed with their stupid Hotmail. [Did you notice that I'm right now ganging up? You get the idea right? It creeps into your life before you realize :)]

When the entire world googles, China goggles at us in protest.

I'm really sorry. Because it was very interesting, I forgot to come back to the climax.

Well, we sort of understood that a gang up leads to the existence of another gang. So, what I'm saying is (idea!) we should gang up in a level where there is no possible another gang at the moment. But you never know.

For example, let's all gang up as Earthlings (creatures, objects on earth) forgetting the all other gangs (some of which I mentioned above). What if we discover aliens in future?!?

Tadaang! We should re-invent our gang! Instead of Earthlings, we should call us and aliens together as Galaxians or Milkywaytes or Univer'saalae's ;-)

God promise, I did not write this in high :)

I put a serious thought in a child's imagination.

Vola! Ciao!

Saturday, January 23, 2010

POETIC SCIENCE: வைரமுத்து

[DISCLAIMER: Strong regional, ancestral, emotional, thrashing, praising and prejudiced content follows. Be warned... :) ]


AAYIRATHIL ORUVAN - LATEST TAMIL MOVIE, IS A DISGRACE TO THE LYRICS OF ONE OF ITS OWN SONGS.

I'm talking about 'Thaai Thindra Manne' song penned by Vairamuthu.

The story this song tells, the thrill it creates can never even cross the wildest dreams of the director or any literary contributor to this movie. Sadly the film failed to match the story and this song.

This is the second time I feel the science of writing. What a scientist would do, so is the writer of this song has done with his writing. Of course the first time being the time of reading Harry Potter. In my opinion J.K. Rowling and Vairamuthu are toxic, hardcore poetic scientists. At last I came to agree that Vairamuthu is really really, a great lyricist.

To blend in the story the song tells, either see the movie or read the following notes and then swallow the lyrics below:

Story of the movie: Due to political reasons or due to destiny, the last prince of cholas was driven out of his country. He crosses seas, wilds, mountains and countries to hide in a place forever in an island near Vietnam. For thousand years, Cholan's heritage continues there and todays king rules a lonely country with a community of Tamil cholas. They await message from Thanjavur forever for generations and generations waiting to return. They eat animal meat because there is no rain hence no way to cultivate rice and vegetables that too for thousand years. They lead a lowly life so to speak. Food is treated bigger than life and ethics. Young mothers ready to sell themselves to get food for their babies. Though their bodies shrinking lean, their pride remains. The king, caring for them no matter what.... with them.... for them... forever....

Suddenly, a virgin from outside world claims that she is chola born and brings message from Tanjavur to bring the king back home. The king(Parthiban) doesn't believe her much, but still agrees to go by whatever she says. He desires to get back to his country thinking that kings time is still there not knowing that there is a republic government ruling all the lands. The song is a pure emotional outburst of the king about the current lowly state, desire to be back in the country and the trust he has on the virgin messenger. Here you go....

THAAI THINDRA MANNE: LYRICS[Find the audio song here]

தாய் தின்ற மண்ணே.... இது பிள்ளையின் கதறல்....
ஒரு
பேரரசன் புலம்பல்
...

தாய் தின்ற மண்ணே.... பிள்ளையின் கதறல்....
ஒரு பேரரசன் புலம்பல்
...

நெல்லாடிய நிலம் எங்கே.... சொல்லாடிய அவை எங்கே.....
வில்லாடிய களம் எங்கே.... கல்லாடிய சிலை எங்கே.....

தாய் தின்ற மண்ணே...... தாய் தின்ற மண்ணே.....
.......!!!!!!!!!!!!!!!!!!


[தாக்கு திக்க..... தக்க தக்க .... தா.... திரனன தா... ஜகதக தா....]


கயல் விளையாடும் வயல்வெளி தேடி காய்ந்து கழிந்தன கண்கள்....
காவிரி மலரின் கடிமணம் தேடி, கருகி முடிந்தது நாசி....
சிலை வழி மேவும் உளி ஒலி தேடி, திருகி விழுந்தன செவிகள்.....
ஊண் பொதி சோற்றின் தேன் சுவை கருதி ஒட்டி உலர்ந்தது நாவும்....
புலிக்கொடி பொறித்த சோழ மாந்தர்கள் எலிக்கறி பொரிப்பதுவோ...
காற்றை குடிக்கும் தாவரமாகி காலம் கழிப்பதுவோ....
மண்டை ஓடுகள் மண்டிய நாட்டை மன்னன் ஆளுவதோ....
மன்னன் ஆளுவதோ... ஓஓஓ...... ஓஓஓஓஓஓஓஓஓஓஓஓஓஓஓஒ.......
தாய் தின்ற மண்ணே... தாய் தின்ற மண்ணே..... .................!

[கல்.... கபட திபட திபட... ----> சனனன... சனனன... சனன.... சனனனனா....
சதுபஞ் சபட சஷ்யா திபட..... ---->
தனனா தனனனா தனன னனனா....
தேகஹா ----> தனனன
திபடஹா ----> நனனன
சதுபஞ் சபட சஷ்யா திபட கா...<---இரு குரல்கள் ஒன்றியது-->
தனனா தனனனா தனன னனனா....]

நொறுங்கும் உடல்கள்.... பிதுங்கும் உயிர்கள்....
அழுகும் நாடு.... (rotting kingdom),
அழுகின்ற
அரசன்... (crying king)

பழம் தின்னும் கிளியோ, பிணம் தின்னும் கழுகோ.....!
தூதோ..... முன்வினை தீ.....தோ.....
கலங்களும் அதிர.... களிறுகள் பிளிற...
சோழம் அழைத்து போவாயோ.....

தங்கமே என்னை தாய் மண்ணில் சேர்த்தால்...
புரவிகள்
போலே புரண்டிருப்போம்....
(குதிரைகள் மண்ணில் புரண்டு படுத்து கிடப்பது போல தன் சொந்த
நாட்டு நிலத்தில் விழுந்து கிடக்க வேண்டும்)

ஆயிரம் ஆண்டுகள் சேர்த்த கண்ணீரை, அருவிகள் போலே அழுதிருப்போம்....
அது வரை அது வரை......ஓஓஓஓஓஓ... ஓஓஓஓஓஓஓஓஓஓஓஓ!

தமிழர் காணும் துயரம் கண்டு, தலையை சுற்றும் கோலே(crown), அழாதே...
என்றோ ஒரு நாள், விடியும் என்றே, இரவை சுமக்கும் நாளே, அழாதே...
நூற்றாண்டுகளின் துருவை தாங்கி, உறையில் தூங்கும் வாளே, அழாதே....
எந்தன் கண்ணின் கண்ணீர் கழுவ, என்னோடழும் யாழே, அழாதே........................!

நெல்லாடிய நிலமெங்கே.... சொல்லாடிய அவை எங்கே....
வில்லாடிய களம் எங்கே... கல்லாடிய சிலை எங்கே...

தாய் தின்ற மண்ணே.... இது பிள்ளையின் கதறல்.... ஒரு பேரரசன் புலம்பல்......

PS:
For English version, you have to wait a little.

For confused souls, a good review just like what I thought about the movie was done by someone else here: http://jaganrules.blogspot.com/2010/01/aayirathil-oruvan.html