Friday, February 28, 2014

Battle of Saragarhi

"21 Sikhs" Fearless fighter Great finghter than 300

"21 Sikhs"

I guess, most of you guys might have seen the movie ‘300’ (based on novel by Frank Miller). If you haven’t, well, watch it. I wont tell that its a master piece but its certainly one of its kind. Extreme boredom on a fine day resulted in watching the movie for the second time and doing a small research on the story line.

Well, these are the important points …

Its about Battle of Thermopylae
Mostly shot before blue screen (read it as lots of graphics)
A huge hit at the box office (what do you expect when 300x6 packs are on the screen fighting like …… uhmm … Vijaykanth or Balayya babu ?)
Spartan King Leonidas is the Hero of the story
Persian ‘God King’ Xerxes is the villian
Fight is between 300 spartans + some guys joined in between And > 1million persian soldiers

But, there are few other things I learned from Wikipedia and Google ….

Persian Army is about 2.6 millions in size
Persian king is actually called as Xerxes, The Great
300 is not really 300 spartans, they are 300 spartans + 1000 Lacedaemonians +
3000 other greek soldiers + 700 Thespians + 1000 Melians +
400 Thebans + 1000 Phocians + few other Opuntian Locrians
The number is around 6400 to 6700 which is NOT equal to 300 

Ah, well, after reading the complete article, I started to believe in the story. Before that .. unless each one of them are like Rajini in Shivaji or Chiru in Tagore or Keanu Reaves in Matrix Reloaded (each fight huge number at a time) they wouldn’t have had stopped the persian army for 3 days.

Okay, now going back to the title, while reading the article about Battle of Thermopylae, few interesting words flashed on the page … Battle, Saragarhi, and Sikhs. This is an interested story, which has roots from India. This is about a battle which is often compared to the Battle of Thermopylae. The Battle of Saragarhi. The battle happened on 12th of September 1897, when India was under British Rule.

The Battle was between 4th Battalion (then 36th Sikhs) of the Sikh Regiment and Afghan and Orakzai tribesmen. It is between … 21 Sikhs and 10000 Afghans. Sikh soldiers managed to stop Afghans till their death and by the time Afghans cleared resistance, reinforcements saving some critical points for British India. The Afghans later stated that they had lost about 180 killed and many more wounded during the engagement against the 21 Sikh soldiers, but some 600 bodies are said to have been seen around the ruined post when the relief party arrived.

Comparing The Battle of Sargarhi and The Battle of Thermopylae, Wikipedia had some interesting numbers. The ratio Spartans fought with Persians was 1 spartan against 28 Persians. While, the ratio Sikhs fought Afghans was 1 Sikh against 285 Afghans. After reading that part of the page … all I could feel is … Wow, our sikhs are the best ! Hope some bollywood producer/director gets to know about this battle and make a movie that total world (or atleast India) will get to know about those brave soldiers. It was their fight to Glory.

Read complete story of this battle
http://en.wikipedia.org/wiki/Battle_of_Saragarhi

The Battle
Members of the 11th Sikh Regiment in 1860
Details of the Battle of Saragarhi are considered fairly accurate, due to Gurmukh Singh signalling events to Fort Lockhart as they occurred.
Around 9:00am, around 10,000 Afghans reach the signaling post at Saragarhi.
Sardar Gurmukh Singh signals to Col. Haughton, situated in Fort Lockhart, that they are under attack.
Colonel Haughton states he cannot send immediate help to Saragarhi.
The soldiers decide to fight to the last to prevent the enemy from reaching the forts.
Bhagwan Singh becomes the first injured and Lal Singh is seriously wounded.
Soldiers Lal Singh and Jiwa Singh reportedly carry the dead body of Bhagwan Singh back to the inner layer of the post.
The enemy breaks a portion of the wall of the picket.
Colonel Haughton signals that he has estimated between 10,000 and 14,000 Pashtuns attacking Saragarhi.
The leaders of the Afghan forces reportedly make promises to the soldiers to entice them to surrender.
Reportedly two determined attempts are made to rush open the gate, but are unsuccessful.
Later, the wall is breached.
Thereafter, some of the fiercest hand-to-hand fighting occurs.
In an act of outstanding bravery, Ishar Singh orders his men to fall back into the inner layer, whilst he remains to fight. However, this is breached and all but one of the defending soldiers are killed, along with many of the Pashtuns.
Gurmukh Singh, who communicated the battle with Col. Haughton, was the last Sikh defender. He is stated to have killed 20 Afghans, the Pashtuns having to set fire to the post to kill him. As he was dying he was said to have yelled repeatedly the Sikh battle-cry "Bole So Nihal, Sat Sri Akal" (Shout Aloud in Ecstasy! True is the Great Timeless One). "Akal," meaning Immortal, beyond death, the Supreme Creator God unbound by time and non-temporal.
Having destroyed Saragarhi, the Afghans turned their attention to Fort Gulistan, but they had been delayed too long, and reinforcements arrived there in the night of 13–14 September, before the fort could be conquered.The Pashtuns later admitted that they had lost about 180 killed and many more wounded[6] during the engagement against the 21 Sikh soldiers, but some 600 bodies are said to have been seen around the ruined post when the relief party arrived (however, the fort had been retaken, on 14 September, by the use of intensive artillery fire, which may have caused many casualties). The total casualties in the entire campaign, including the Battle of Saragarhi, numbered at around 4,800.

Wednesday, February 12, 2014

Big 'O' notation for Java Collection


Big 'O' notation and Java Constant time performance


Collection Constant time performance, in a line is "The same amount of time taken for a certain operation(method) regardless of the number of elements in the collection"

Big 'O' notation

http://en.wikipedia.org/wiki/Big_O_notation


The Big O notation is used to indicate the time taken by algorithms to run :-

For example:-
(N is the number of elements)

O(N):- The time taken is linerarly dependent to the number of elements.

O(log N):- The time taken is logarithmic to the number of elements.

O(1):- The time taken is constant time, regardless of the number of elements.

Please read here to find out about the big O notation:-

In java collections 

Sets

1) The HashSet offers constant time performance for basic operations (add, remove, contains and size).

2) The TreeSet provides guaranteed log(n) time cost for the basic operations (add, remove and contains).

3) Like HashSet, the LinkedHashSet provides constant-time performance for the basic operations (add, contains and remove)

Lists

4) The ArrayList offers constant time performance in the size, isEmpty, get, set, iterator, and listIterator operations. The add operation runs in linear time. All of the other operations run in linear time (roughly speaking).

Maps

5) The HashMap provides constant-time performance for the basic operations (get and put).

6) The TreeMap provides guaranteed log(n) time cost for the containsKey, get, put and remove operations.

7) Like HashMap, the LinkedHashMap provides constant-time performance for the basic operations (add, contains and remove), assuming the the hash function disperses elements properly among the buckets.

If you need a List you could use the ArrayList.

If you need a Set use the HashSet or for a sorted set use the TreeSet or an insertion ordered set use the LinkedHashSet.

If you need a Map use the HashMap or for a key sorted map use the TreeMap or a key insertion ordered map use the LinkedHashMap.

Followers

Total Pageviews