### Algorithms in Java

Most algorithms in Java operate on list instances and subsequently with other collection instances. The different algorithms used in Java are:

• Sorting
• Shuffling
• Routine Data Manipulation
• Searching
• Composition
• Finding Extreme Values

Sorting

The sort algorithm reorders a List so that its elements are in ascending order according to an ordering relationship. Two forms of the operation are provided.

FORM 1

The simple form takes a List and sorts it according to its elements’ natural ordering.

The sort operation uses a optimized merge sort algorithm which is fast and stable:

• Fast: It is guaranteed to run in n log(n) time and runs substantially faster on nearly sorted lists. Empirical tests showed it to be as fast as a highly optimized quicksort. A quicksort is generally considered to be faster than a merge sort but isn’t stable and doesn’t guarantee n log(n) performance.
• Stable: It doesn’t reorder equal elements. This is important if you sort the same list repeatedly on different attributes. If a user of a mail program sorts the inbox by mailing date and then sorts it by sender, the user naturally expects that the now-sequential list of messages from a given sender will (still) be sorted by mailing date. This is guaranteed only if the second sort was stable.

FORM 2

The second form of sort takes a Comparator in addition to a List and sorts the elements with the Comparator.

Shuffling

The shuffle algorithm does the opposite of what sort does, destroying any trace of order that may have been present in a List. That is, this algorithm reorders the List based on input from a source of randomness such that all possible permutations occur with equal likelihood, assuming a fair source of randomness. This algorithm is useful in implementing games of chance.

This operation has two forms:

One takes a List and uses a default source of randomness, and the other requires the caller to provide a Random object to use as a source of randomness.

Routine Data Manipulation

The Collections class provides five algorithms for doing routine data manipulation on List objects, as listed below:

• reverse — reverses the order of the elements in a List.
• fill — overwrites every element in a List with the specified value. This operation is useful for reinitializing a List.
• copy — takes two arguments, a destination List and a source List, and copies the elements of the source into the destination, overwriting its contents. The destination List must be at least as long as the source. If it is longer, the remaining elements in the destination List are unaffected.
• swap — swaps the elements at the specified positions in a List.
• addAll — adds all the specified elements to a Collection. The elements to be added may be specified individually or as an array.

Searching

The binarySearch algorithm searches for a specified element in a sorted List. This algorithm has two forms.

1. The first takes a List and an element to search for (the “search key”). This form assumes that the List is sorted in ascending order according to the natural ordering of its elements.
2. The second form takes a Comparator in addition to the List and the search key, and assumes that the List is sorted into ascending order according to the specified Comparator. The sort algorithm can be used to sort the List prior to calling binarySearch.

The return value is the same for both forms.

Composition

The frequency and disjoint algorithms test some aspect of the composition of one or more Collections:

• frequency — counts the number of times the specified element occurs in the specified collection.
• disjoint — determines whether two Collections are disjoint; that is, whether they contain no elements in common.

Finding Extreme Values

The min and the max algorithms return, respectively, the minimum and maximum element contained in a specified Collection. Both of these operations come in two forms.

The simple form takes only a Collection and returns the minimum (or maximum) element according to the elements’ natural ordering.

The second form takes a Comparator in addition to the Collection and returns the minimum (or maximum) element according to the specified Comparator.

`Source: The Java™ Tutorials`

### Java Collection Framework

A collection or container is an object that groups multiple elements into a single unit, they are used to store, retrieve, manipulate and aggregate data.

# Collections Framework

A collections framework is a unified architecture for representing and manipulating collections. All collections frameworks contain the following:

• Interfaces: Interfaces are abstract data types that represent collections. Interfaces allow collections to be manipulated independently of the details of their representation. In object-oriented languages, interfaces generally form a hierarchy.
• Implementations: These are the concrete implementations of the collection interfaces. Implementations are reusable data structures.
• Algorithms: Algorithms are the methods that perform useful computations, such as searching and sorting, on objects that implement collection interfaces. The algorithms are said to be polymorphic: that is, the same method can be used on many different implementations of the appropriate collection interface. Algorithms possess reusable functionality.

Interfaces

The  collection interfaces encapsulate different types of collections. These interfaces allow collections to be manipulated independently of the details of their representation.

• Collection — the root of the collection hierarchy. A collection represents a group of objects known as its elements. The Collection interface is the least common denominator that all collections implement and is used to pass collections around and to manipulate them when maximum generality is desired. Some types of collections allow duplicate elements, and others do not. Some are ordered and others are unordered. The Java platform doesn’t provide any direct implementations of this interface but provides implementations of more specific subinterfaces, such as Set and List.
• Set — a collection that cannot contain duplicate elements.
• SortedSet — a Set that maintains its elements in ascending order. Several additional operations are provided to take advantage of the ordering. Sorted sets are used for naturally ordered sets, such as word lists and membership rolls.
• List — an ordered collection (sometimes called a sequence). Lists can contain duplicate elements. The user of a List generally has precise control over where in the list each element is inserted and can access elements by their integer index (position).
• Queue — a collection used to hold multiple elements prior to processing. Besides basic Collection operations, a Queue provides additional insertion, extraction, and inspection operations.

Queues usually order elements in a FIFO (first-in, first-out) manner.

• Deque — Similar to queue but Deques can be used both as FIFO (first-in, first-out) and LIFO (last-in, first-out). In a deque all new elements can be inserted, retrieved and removed at both ends.
• Map — an object that maps keys to values. A Map cannot contain duplicate keys; each key can map to at most one value.
• SortedMap — a Map that maintains its mappings in ascending key order. This is the Map analog of SortedSet. Sorted maps are used for naturally ordered collections of key/value pairs, such as dictionaries and telephone directories.

If an unsupported operation is invoked, a collection throws an UnsupportedOperationException.

Note:  All core collection interfaces are generic.

`Source: The Java™ Tutorials`

### India – Winners Under 19 Cricket World Cup : “The Wall” with twigs

ICC U19 World Cup 2018 is special for India because the performance of this team has been clinical and simply outstanding.  Look at the track record starting from match 1 that India played in this tournament.

Group Matches

India won by 100 runs vs Australia

India won by 10 wickets vs Papua New Guinea

India won by 10 wickets vs Zimbabwe

Super League quarter-finals

India won by 131 runs vs Bangladesh

Super League semi-finals

India won by 203 runs vs Pakistan

Final

India won by 8 wickets vs Australia

The margin and the rate at which these boys have won matches has been phenomenal.

One man behind this stupendous show is ‘The Wall – Rahul Dravid’. Not to forget the contribution of other coaches and support staff involved with this team. Dravid, would definitely be a happy coach after winning the cup which his boys(different team) had lost a couple of years ago in the final.

This is India’s 4th title overall and 1st on New Zealand soil at under 19 level.

Things that this lads would have definitely learnt from Rahul Dravid:

i) To score runs patiently.

ii) To put a price on their wicket.

iii) To care for every single run.

Prithivi Shaw, Shubman Gill, Manjot Kalra, Anukul Roy have been the pick of this tournament.

Rahul Dravid comes from the old school of thought in going through the grind to master skills. This can be seen even today when he instructed the young boys to stay away from mobile phones till finals and concentrate on the tournament instead of IPL auctions.

Well, I remember reading in local newspaper that Dravid owns a plot in HSR Layout, wish he builds a home here so that I can meet him sometime in the future and brag he lives in my neighborhood.

Harsha Bhogle had once called Dravid as “the Wolf who lived for the pack”, well the wolf has grown now to guide the whelps.

Congratutions to U19 Indian cricket team and the coaches, including Rahul Dravid.

### India : The Dark Horse

Let us understand and discern what population of India can deliver.

As of 2016 our population is 1.324 billion which translates to 132 crores(approximately).

Adult literacy rate is 72.1%(2015), assuming this population can do basic reading and writing.

Keeping the same percentage for 2016 would translate to 95.17 crores. If we consider 10% of this population to be the cream i.e. approximately 10 crore Indians would be the think tank of this country.

India is a mouth watering market for any tech company/startup today because India offers a sizable population to operate for these companies and also provides the demographic variety. So any company, if not now probably in the coming days would first want to test it’s product here before launching it globally.

Let us look at the sectors which offer opportunities :

1. Internet – Has changed the way Indians live in the last 10 years, will continue to grow with the same pace with cheaper data rates and increasing mobile users.
2. Infrastructure – Offers an extremely promising landscape provided there are easier policies while executing projects.
3. Transportation – This is one sector which can bring perennial windfall of wealth if revamped and redesigned different routes with ports of this big nation.[looks like IIT(Internet, Infrastructure and Transportation) occupies the top place here too, just kidding there is nothing like top in this list as all these sectors give enough scope and space for development]
4. Healthcare – One booming sector which is embracing and adapting to change quickly, with ageing population. It can be a mammoth sized industry if nurtured from grass-root level.
5. Sports & Fitness – In one sentence this can be defined as the industry which requires immediate attention.
6. Clean Energy – With depleting levels of non renewable energy sources it’s time to look for renewable sources as India provides ample opportunity with varied climatic condition throughout the country.

There are industries which give abundant opportunities upfront such as agriculture, education, FMCG, etc. The above mentioned list of industries are for an  individual who wants to unlock potential with increasing population.

As a society, we are evolving from a large sized group to nuclear groups which is a necessary and more viable option in an urban mindset. It is more to do with can do approach rather than what if.

Population proliferation can be beneficent if acted upon now. That does not validate the fact that this trend must continue. There needs to be more opportunities for people who want to take risks by giving creative freedom, irrespective of results. This attitude will bring upon a change in how younger generation perceive their world within and outside themselves.

The horse is ready to gallop, time for jockey !

```Data Source:

Population - World Bank.

Literacy rate - Wikipedia.```

### Indian

The highest form of endowment that I will ever possess will be the fact that I am an INDIAN.

India, the land of cultural resonance shall always hold a unique place on the globe.

Being Indian makes me rise above religion, caste, creed, state, language and many such boundaries.

This rich nation, has made me richer in every aspect, more so culturally. Probably, if not for India, I would have never had an opportunity to learn/speak Kannada, Hindi, Tamil, Telugu or English and enjoy the variety from myriad sources of this great nation.

Politically there may be leftist and rightist ideologies. But common man needs neither of them. Clearly, people of India need a rationalist movement.

Bhagat Singh was an atheist.

Swami Vivekananda believed in service to mankind.

APJ Abdul Kalam preached science as a tool for self reliance.

Verghese Kurien started white revolution.

Vikram Sarabhai stands as tall as Bahubali(Mahaveera) in Indian space research program.

All the great names mentioned above belonging to different religion such as Sikhism, Hinduism, Islam, Christianity, Jainism have co-existed and contributed for overall development of this nation.

Mahatma Gandhi inspired a whole new generation across the world.

The biggest strength and weakness of current India is population. It is a strength because we have the largest youth population on this planet. It is a weakness since the opportunities are limited.

If we are to gain advantage over other nations and become a global power house, it’s about channeling youth energy.

India will overcome it’s shortcomings in the upcoming years, the Millennials will  be operating for the next 10 years. Yes, the millennials are avert to many concepts, but they will be the key in shaping future India. One hurdle for millennials shall be capitalism versus socialism which millennials can pass through with time and experience.

Happy Republic Day everyone.

26th January, the day when India became a republic and constitution came into existence.

Constitution of India

The Indian Constitution has been a sovereign symbol of this glorious nation. For people who want to read and download the constitution please find the link below.