Find Nth Largest number in an Array August 12, 2008
Posted by Thinker in General.1 comment so far
The below is my implementation of finding the nth largest(whichmax)number in the given array of integers.
This would work for both positive and negative integers. This also affects the given array by manipulating the values of the source array. Hence if you want an non-manipulative algo, this is NOT the one.
#include “stdafx.h”
class Program
{
public:
int GetNthLargestOptimized(int **intArray,int Length, int whichMax);
};
int Program::GetNthLargestOptimized(int **intArray,int Length, int whichMax)
{
int MaxIndex =0;
int MinIndex =0;
bool minFound = false;
for(int nth=0;nth<whichMax;nth++)
{
for(int index=0;index<Length;index++)
{
if((*intArray)[MaxIndex]< (*intArray)[index])
{
MaxIndex = index;
}
if(!minFound && (*intArray)[MinIndex] > (*intArray)[index])
{
MinIndex = index;
}
}
if(!minFound)
{
minFound = true;
}
if( nth != whichMax -1)
{
(*intArray)[MaxIndex]= (*intArray)[MinIndex];
}
}
return (*intArray)[MaxIndex];
}
int _tmain(int argc, _TCHAR* argv[])
{
Program m;
int intNegativeArray[10]={-1,-2,-3,-4,-5,-6,-7,-8,-9,-10};
int intArray[10]={23,345,345,12,45,23,34,4,6,555};
int *intNegativePtr = intNegativeArray;
printf(“4th Largest in Negative array:%d\n”,m.GetNthLargestOptimized(&intNegativePtr,10,4));
int *intPtr = intArray;
printf(“4th Largest in Positive array:%d\n”,m.GetNthLargestOptimized(&intPtr,10,4));
return 0;
}
Live Writer March 5, 2008
Posted by Thinker in General.Tags: Microsoft Live Writer
add a comment
I am writing this from the live writer. This is becoming really interesting to blog. The only hitch that i have now is that, the WordPress themes do not jewel well into the writer. So I am using the Normal view to blog into the wordpress.
This looks very interesting though
Been away from Blogging December 8, 2006
Posted by Thinker in General.1 comment so far
I have been bit busy personally and officially for last several months to be away from blogging..
Atleast now i feel i should devote some time back to blogging.
In Chennai this week end. August 11, 2006
Posted by Thinker in General, India.2 comments
I would be in Chennai this week end. So expect a post after 17th. Till then i would most probably not post:)
You are looking at an Featured Blog by WordPress. August 6, 2006
Posted by Thinker in General, Reservation in India.add a comment
Yes, my blog is a featured blog under “Reservation in India” category. Visit :http://wordpress.com/tag/reservation-in-india/ this link…
Lets improve the education of Backward Classes May 30, 2006
Posted by Thinker in General.5 comments
The trick has payed off.. These dirty guys of politicts wanted to divide us in the name of caste.. and what an irony.. We now stand divided. The divion of OBCs and Forward caste.. is becoming more relevant now. At this point, i thought, let me not just take part in agitation against reservation, Reservation is the whole point to get the society divided on the basis of caste and creed and to garner votes!
I am planning to do social service to visit villages near to my current residance and help poor students get some good education. I feel the need of the hour is not Reservation, the need of the hour is social service!
We need to improve the conditions of the poor people of India, they may be from back ward caste, they may be from forward caste, i dont care. We need to help them get good education.
I want India to be a great place to live, i want humanity to spread love and affection towards all.
I carve for unity , I carve for a united India, I carve for a political setup that works only for the harmony of the people. I hate this dive and rule policy of Reservation.
I feel the best way to improve the economically backward class (I hate to call some people as backward class just because they were born in a specified caste!), is to set up good educational institutes near to their home and give them quality free education that facilitates them to take on the best of the breed!
This is definelty possible with a honest commitment from the governement and if followed religiously without any discrimination on caste ,creed, religion or region, it is a way to a successful india.
The alternative to reservation is to provide education to all and make all classes competent and competitive. Let us help the poor class to get good education. This is a postive approach to the problem.
I am against any split in India on the name of Caste , Creed, Religion or Region!
Lets do good to fellow human beings.. let us spread the message of Love.
Jai hind
Aravinthan.
South India – A lesson to be learnt for the forward community. May 29, 2006
Posted by Thinker in General.6 comments
Some excerpts from NTDV.com URL: http://www.ndtv.com/template/template.asp?fromtimeline=true&id=88471&callid=1&template=Reservation
“Brahmins of Tamil Nadu are like the Jews of Germany. They are not being physically liquidated but they are being suffocated and squeezed educationally,” said former UN information consultant SR Madhu.
“Tamil Nadu’s quota, which stands at 69 percent has effectively driven the forward community out of the state.” – NDTV.
So guys if you dont come to the street and protest against this discrimination that is being carried out, North India would also end up like the south.
We need to analyse how the Tamil Nadu goverments (Dravidian parties) were able to effectively rout most of the Brahmin community out of Tamil Nadu and how we can help them get back there. Without our support they can never survive. And If we take this lightly, the same scenario might spread across the whole of India which is very much a worrying factor.
Subash Chandra Bose – Why Britishers left India? May 28, 2006
Posted by Thinker in General.5 comments
Some exerpts from a grandson of an INA Army person: Courtesy Rediff.com (see the link above).
In post-Independent India the INA’s role was played down. The official evaluation was that its activities had little effect. Militarily speaking that was true because the army was not that well equipped, but the British made a great political mistake by putting three INA officers on trial at the Red Fort (in Delhi), expecting that people would look down on them as traitors. The opposite happened and the trial publicized the efforts of the INA, which had previously been censored.
Until the trial little had been known of the INA or the Government of India in exile in 1943 when they tried to send food to Bengal during the Great Famine. All of a sudden this trial made everything known and it revived the struggle for independence in India, which had been lagging because the leadership of the Congress party and other groups mostly had been imprisoned. Their efforts like the Quit India movement had not been successful and so this gave a new dawn to the movement.
As a consequence of the INA’s efforts, large numbers within the British Indian Army — which was not just British but for the most part Indian — became unreliable. There was a mutiny in Bombay (by the Royal Indian Navy), which showed the armed forces could not be depended on. The administrative system was what had controlled India and with the army unreliable the British realised India could not be held as a colony any more. This led to the transfer of power. It was meant to have taken place a few months later, but it was brought forward to August 1947.
You could therefore say the INA had this effect of destabilising the British hold on the Indian army and reviving the independence movement within India.
The INA certainly has its place in Indian history.
When the first few INA soldiers returned to India they were treated as heroes, but I must say in the later stages India has not treated them very well. The INA veterans were not recognised as army veterans and for a very long time they were not even recognised as freedom fighters, which meant that certain benefits such as a pension and free rail travel were denied to them. Many members of the INA were reduced to poverty and some of them died in hunger. These were simple people and could not find their way that easily in the country to which they returned.
India has not behaved towards this group in an honorable or fair way.