Thursday, January 26, 2017

Top 5 places to visit in Nova Scotia - in 3 days


Travelling. It leaves you speechless. Then turns you into a storyteller. - Ibn Battuta

An Evening in Bay of Fundy - Nova Scotia

There are certain places in the world, the beauty of which cannot be described with images of any resolution or words of any language. You simply have to witness them through your own eyes. Nova Scotia is one such place.

Inspiration:


Every province in Canada has a lot to offer. A lot more than you can cover in one trip. Nova Scotia with its miles long coastline along the majestic Atlantic ocean, wildlife and breathtaking trails is no exception to that rule.This maritime province is flooded with natural beauty, greenery and culture. If you are a photography enthusiast, you would not have time to breath.

When it comes to choosing a destination for my next travel plan, I gravitate towards one with a lot of natural beauty to explore. Definitely while in Canada, Nova Scotia was bound to be on my list.I shared this wish with a few of my friends who shared the same enthusiasm about travelling to places and boom!!, we were ready to fly. But considering the fact that we could only use long weekends (a weekend with either Monday or Friday as a holiday) for our travel plans, we had a tough call to make. We had to choose what to see from the long list of must see attractions in Nova Scotia. Here's a quick list for your reference:


Must see attractions:

  1. Halifax
  2. Peggy's Cove
  3. Lunenburg
  4. Bay of Fundy
  5. Cape Breton Highlands National park
Looking at the list superficially, one may think that the list is small, but let me stop you right there. These are just names. Each of it is a reservoir of  beautiful attractions and not to miss sites/activities in itself. Nova Scotia is one such place where any trip will feel short. But probably a weeks trip should be good if you would like to experience Nova Scotia as a traveller.


Must do activities:

  1. Whale watching
  2. Tidal bore rafting 
  3. Witnessing the world's highest tides in Bay of Fundy.
  4. Cabot Trail
  5. Hiking/biking/kayaking/canoeing 


Elimination Round/choosing what we can afford to miss:


Each and every place listed above offers a unique experience and hence is kind of a must. It was nearly impossible to play favorite between them. But then we had limited money and time and exactly one driver. This helped us narrow down our choices. We had to come up with a set of places we could cover in one trip spanning 3 days and 4 nights including the time to travel from Toronto to Nova Scotia.

The Province of Nova Scotia can be broadly seen as two parts: The mainland and the Cape Breton island. While Halifax, Peggy's Cove, Lunenburg and Bay of Fundy are located on the mainland, the island is home to the great Cabot Trail. Both of them cannot be covered in a single 3 day trip. Its either mainland or the island. We chose mainland because it involved less driving and we were particularly fascinated by the Bay of Fundy.

If you choose to go to Mainland, there are flights from Toronto Pearson airport as well as the Billy Bishop Island airport to Halifax. If you are planning to go to the Cape Breton Island instead, the better option would be to choose to land in Sydney (Nova Scotia not Australia).

Our Itinerary

Our Nova Scotia Itinerary

What's Interesting


The Flight


We were excited even before we reached Halifax as we had chosen to start from the iconic Billy Bishop (BB) Island airport. This is the beautiful island airport easily accessible from downtown Toronto. The flight was decent but really enjoyable for us because it was first time for all of us to fly from BB.

Billy Bishop Airport Toronto and CN tower in the shadow 😊

Halifax ( Morning to late night)


No matter if you are a strolling kind like me, a night owl, no actually a bat (Bat is my brand ambassador), or a history buff, you will find plentiful in Halifax.

They call it a walk-able city. After living in a big city like Toronto for a while when we visited Halifax, it felt charming and it was indeed walk-able. We experienced most of Halifax on our feet. After having an early stomach full breakfast buffet at the downtown hotel we stayed at, we headed for the tour on foot. Strolling around the city downtown, we visited the old town clock, the Citadel and other buildings around downtown before we had an Indian buffet lunch. I don't remember what we had in lunch though. Forgive me for that. Will ya?

The Old Town Clock

As the Park's Canada site says, the Citadel delivers history with a bang! The noon gun is a not to miss attraction. I don't know at this moment how I can share the heavy video on this blog. (An action item for me)

The bats have no reason to be disappointed either. The Lower Deck is just a place to go. Here you can meet locals, dance to the ever running stream of loud music and enjoy a local brew.

After the relaxing day at Halifax, we headed for the next big thing. Peggy's cove.

Peggy's Cove (3 Hours)


Peggy's cove - Most photographed in North America - rightly so.

The treacherous tides of the deep blue ocean crashing on the beautiful rocks at the Peggy's cove will keep you stunned for hours. The roughly three hours that we spent here felt like minutes. I don't have more words to describe it and hope that the picture says it all.

If you have visited a lighthouse by the ocean before, you know exactly what to expect. Having said that, when you visit this one, you will know why this is the most photographed place in North America.

I had something at the Sou'wester Restaurant which probably did not go as expected. I think it was boiled salmon and I am not a seafood lover. Still I tried it because I was not sure when I will get another chance of having a fish by the Atlantic. But the famous Nova Scotia Haddock Fish and Chips would mostly be a good try if you are a seafood lover. One of us had it and I guess enjoyed it.


Lunenburg (Roughly 1 day)


Lunenburg with its colourful houses

This UNESCO world heritage site is known for its vibrant and colourful homes. Driving through it's narrow streets overlooking beautiful houses and farmer's markets we reached our destination - the whale watching centre.

The whale watching experience is absolutely breathtaking, weather you see a whale or not. Experiencing the waves miles into the ocean when you cannot see any shore has no match from land. The waves that we peacefully appreciate from the shore take the form of giant beasts with tremendous power. You can feel the overwhelming power of a wave when it gulps your entire boat carrying at least 40 people and throws you right back as if it does not care for your tiny existence. And yes, all this when the weather report says that the ocean is calm. The thought that how tiny and vulnerable you are haunts you. But after all when you see how comfortably the whales of a size of a truck roam around and how the seagulls coexist with them, you are rendered speechless.


Whales playing in the ocean

After this amazing experience, on our way to Bay of Fundy, we grabbed all the food we would need for this and the next day. It's hard to find anything at the Bay.


Bay of Fundy (Plan to be at the bay in the evening, early morning and noon)


This one is my personal favorite and at least according to me the star of the trip. One of the 7 wonders of North America and home to the highest tides in the world, it is also one of the natural wonders of the world. This is the place where you can get a feel of the daily movements of the mother earth.

Every 6 hours the bay fills and empties billions of tonnes of water due to the tidal effects. This causes the sea bed to be exposed and immersed in deep water every 6 hours. While at times you can walk on the sea bed, at other times you may have to take a boat.

The Bay of Fundy is large and there are a lot of places on the bay where you can stay.

We had booked Shangri-La cottage at one such location which was at the heart of all the water activity. All I can say about this cottage is that I would definitely recommend it to who ever consults me.

The Shangri-La cottage we stayed at

After spending an extremely relaxing evening at the camp fire by the cottage by the most amazing bay on earth, we woke up early in the morning to see the tidal effects at 6 AM while the sea bed was still visible and then at noon when the bay was almost filled with the water and had already started getting empty for the next emptying session. At this moment you can observe waves coming from both directions. An effect similar to the one seen when we shake a glass of water.

Bay of Fundy- Half way empty

Bay of Fundy - Full

After relaxing in the afternoon, we snail speed drove on the serpentine roads with no one in site except miles of farmlands, sheep and occasional scarecrows to the Shubenacadie river. I guess you can do tidal bore rafting around Shubenacadie. If you have time, I guess there are a lot of activities you can do here.We just stayed there for some time, did some hiking and headed back to the Halifax airport saying good bye to the wonderful times and the province of Nova Scotia.


What's left


Cape Breton island with attractions like the world famous Cabot Trail, the Fortress of Louisbourg, wildlife and innumerable hiking trails is definitely a must go and is on my list already. It has a lot of unique adventure to offer. I will create an Itinerary for it when I have experienced it.

Please let me know if this itinerary was helpful and I will share more such itineraries as I travel more.

As usual, comments/appreciation/criticism (a constructive one of course) everything is most welcome and appreciated.

Until then,
Happy Learning!
Banyan Bat

Saturday, January 14, 2017

What I learnt from Steve not Steve Jobs

Something that's hard to get unless on Facebook 😊

A couple of years ago, some of my friends and I were in Mumbai, India. One of these friends had just bought a new car and he was excited about it. He wanted to take us on a ride. Largely to show his new car I would guess. He is also the kind who would go into the most glamorous store, dream about how he would choose the best product in that store and walk out of the store, of course buying exactly nothing.

So, he got into his car along with us of course, put his seat belt sunglasses on, played a rock song on the custom music system and headed to one of the newly constructed malls. Learning a lot of features about the car and the custom features installed just for my friend, we reached the mall.

Strolling in the mall, we came across a Bose showroom. "Lets go and have a look. What say guys?" the enthusiastic one insisted and rest of us followed.

I don't clearly remember the name of the guy who greeted us, lets call him Steve. After the last post, that's what came to my mind first. Informing us that he is there to assist us if anything needed he let us go on our own.

After looking at all the wonderful and grossly out of budget products from Bose, while we were about to leave, I witnessed something that would teach me a key business principle and change my opinion for Bose forever.

Steve: Sir, we have a demo for the best product form Bose and I would like you to see it.

     All of us in chorus: Well, no. Its Okay.

Steve: Why not? It will take only 10 minutes or so and you would enjoy it.

     Someone among us: No, Really its Okay! We won't be able to buy it anyway.

Steve: That's okay sir, not today, but may be tomorrow you will.

     All of us in chorus again: Okay.

We listened to the demo of a home theatre system from Bose that would roughly cost about $5000 or INR 3,00,000. A product that would probably suit a room that matches its standards. A product that we would probably not buy in our life time. (At least not me. And definitely I am not going to under estimate my friends. Rather I wish they buy such a system if they wish to). We thanked Steve for a wonderful demo of the product and we left the store.


"Treat the customer with dignity and respect, even if he or she chooses not to do business with you. Finish Strong!" -  Shep Hyken

I think Steve justified the above quote and even went an extra mile in doing that as none of us were existing customers and probably did not even show any signs of remotely thinking of becoming one ever or probably he was simply trying to finish his target. I crossed that later thought intentionally because I would like to think that the farmer is true and is one of the real keys to success.

What this whole incident has done is that it has put a permanent mark on my mind saying out loud: Bose is great!! If you ever get so much money, don't think twice and go buy a Bose product.

Okay, but what was in it for Steve? Steve must have inherently felt good after we left happily. More importantly, he has created a tiny source of positive vibrations for him for the rest of his life. And in doing so, he could not stop himself from helping Bose leave a lasting impression.

On that note I would like to finish this post.

As usual, comments/appreciation/criticism (a constructive one of course) everything is most welcome and appreciated.

Until then,
Happy Learning!
Banyan Bat

Monday, January 9, 2017

The one Step you need to win a customer for life - and how Apple did it



"You have got to start with the customer experience and work back towards the technology - not the other way round." - Steve Jobs

"One customer well taken care of could be more valuable than $10,000 worth of advertising." - Jim Rohn


Recently while I was working on my 4 year old Macbook, it suddenly got sick and would not boot up. [Okay, I was watching a movie, but still it was work for my computer, eyes and brain].
I tried a couple of times with no luck. Immediately I went to my phone and said: "OK Google, Macbook pro not starting with a folder and question mark".

The first result I got was the Apple support site with exactly what I was looking for: a solution to the problem I just told Google. I read through all the possible solutions and unfortunately none worked. The only solution that applied to my situation read something like this: "Your mac may need a repair. Please book an appointment at your nearest Genius Bar". I thought, great, its a nice excuse to hit a bar for a chilled pour. But to my disappointment, Apple calls its tech support station a Genius bar.

Me - "Looks like its time to buy a new laptop." My last laptop went on ventilator early in its 4th year and died soon after. This one was also in its 4th year, so that was a reasonable assumption. I also thought may be, I would not go for a mac again, after all its costly. Those were scary and sad moments. But before that, I had to give it a try for its repair.

As suggested by Google, I booked an appointment at the nearest Genius bar. The appointment was 4 days later. Without a laptop, days are slow :). During the days we were waiting for the appointment laptoplessly, I was suggested that I should go for a local repair store instead as they may charge less as compared to the coveted brand store. But I thought, lets give it a try at the store, ask them for a quotation and then decide what to do.

Finally the day of my appointment came. I had an appointment at 5, just after the end of my workday. Usually that's just fine, but Murphy's law kicked in. I had some urgent work to complete in the office at the same day and I missed my appointment by just 15 mins. When I reached the Genius Bar, it was crowded with a long queue full of people waiting for their turn. These were the people who get a chance when people like me screw up. I reached out to one of the associates at the Genius bar and asked if I can be squeezed in. As I had already guessed, he suggested otherwise, and the next available appointment was in the next week. I got disappointed by the thought of waiting for another week. But then he suggested that we could try another apple authorized store which is less crowded considering that it does not have the big logo on its front door.

Without wasting any time, I rushed to that store. When I reached the service desk, I was greeted with a welcome just like any other store. Then I told my problem quickly and handed over the laptop. The service desk associate ran some diagnostic tests and told me that it would be a couple of minutes before she can tell me whats wrong. Those 2 minutes were long. (In my head: oh man, whats f*#%ed?, how many dollars will I have to pay?, will all my data be lost?, will I have to buy a new laptop? I cannot afford a new Macbook again :() And then the service desk associate said, she believes she knows the problem. I said, oh, what is it? "The laptop is not booting because the cable connecting the motherboard with the hard drive is dysfunctional." I said okay, but is it repairable?
She said: "Of course, and you know what, you would not have to pay a penny as both the diagnosis and the repair for this particular problem are covered by Apple." She continued: "Apple recognizes that quite a few customers who bought laptops in mid 2012 faced this issue and hence, apple decided to bear the cost."

That was relaxing. More than that it was enriching.  Immediately, I felt pampered. All the thoughts that had crossed my mind a minute ago including the thought that I would not go for a mac again were gone and I was happy. Instantaneously I decided that eventually when I do have to buy a new computer, it would be nothing else but mac again.

It was a four years old mac, I personally don't think Apple had any obligation towards it. They could have easily charged me for the diagnosis as well as the new cable. I think most of the other companies would do the same and that would in no sense be unfair. After all the laptop had functioned optimally for last four years. But Apple decided to go the extra mile and honour the repairs even after the warranty period.

It's probably not a big deal for a giant like Apple to do such small services for free. But at the same time, being such a success could have possibly made them think that they don't need to care for such small details. I believe that it takes courage and dedication to do such small things and these simple and small things are the ones which give big rewards and make a difference between success and average, let alone failure.

All this is on top of the fact that the original product is the best. The mac as a product is surely unbeatable. Be it hardware, software, the presentation or the fine details, mac beats most others on each and every aspect.

So, probably the key to success is to build your craft, refine it day and night, pay attention to detail and most importantly, stay humble.

As usual, comments/appreciation/criticism (a constructive one of course) everything is most welcome and appreciated.

Until then,
Happy Learning!
Banyan Bat

Monday, January 2, 2017

Binary Insertion sort - Getting speed

"Please lord, let me prove that winning in the casino won't spoil me." - Bubbly
After we helped Bubbly arrange her cards, she was rocking in the casino. She is now a winning sensation in the Venetian. But as her game has improved, so has her need to be faster and smarter with her cards.

So far as I remember, we had used the fastest way we knew to get her cards sorted. But now with her improved game and competition, that seems slower and we need to find even faster ways to get her cards in order.

Is there a way we can achieve this? Lets try to find out by carefully examining how the Insertion sort works.

As you must have noticed in the post Bubbly goes to Las Vegas, insertion sort works by taking one element at a time, searching its sorted position in already sorted partial array and putting it there. To search this position, we iterated over all the elements in the partially sorted portion linearly and compared the element at hand with each element until we got the desired sorted position for this element.

Let me highlight a few keywords in the above statement : insertion sort works by taking one element at a time, searching its sorted position in already sorted partial array  and putting it there.

If you are following this blog, which I wish you were but I am sure you are not,  you would remember from the post You are searching so hard..., that our study for sorting started because searching in a sorted array is faster.

As can be seen, the insertion sort as of now searches for the element position by simple iteration and comparison which does not take into consideration the fact that we know the arrangement of numbers in the already sorted array. This type of search is called a linear search. This is fine for a small array. But for a larger array this can turn out to be slower as irrespective of the position of the to be searched element in the array, we will iterate through all the elements until we find the one we are seeking. So what is it that we can do so that this search will happen faster?

Binary search for rescue:

I am quite sure, most of you already know Binary search as well. Have you ever played the game "Guess the number", where you ask your friend to pick up a random number and tell them that you will  guess it? Those who answered yes instantly already know the Binary search algorithm. And for others, A quick refresher.

Lets assume that Bubbly and her friend Silly are playing this game.

Bubbly: Hey Silly, wanna play a game?

     Silly: Of course, I am game for a game. Always!

Bubbly: Ok Its a game of numbers.

     Silly: Maths?? :( No way.

Bubbly: Don' worry, you don't have to do any math. You Just have to pick a number between 1 to 10 and I will tell you what number you picked.

     Silly: That sounds fun.

Bubbly: I will guess the number but if its incorrect, I will ask you some hint questions and I would expect you to be honest with me.

     Silly: Fair enough!

Bubbly: Ok so lets get started. Pick a number between 1 to 10 and don't tell me the number. :)

     Silly: umm.. (7)...ok I did.

Bubbly: OK. Let me guess!!.. ummm Is it 5?

     Silly: Nope :).

Bubbly: Okay, is it less than 5 or greater than 5?

     Silly: Greater. As if she is ever gonna be able to tell me what I picked. HAHAHAHA

Bubbly: Okay! Is it 8?

     Silly: Nope, no no.

Bubbly: Okay, is it less than 8 or greater than 8?

     Silly: Less. Oh man, how is she closing in on the number?

Bubbly: Okay, is it 6?

     Silly: Nope. You are never going to find it.

Bubbly: Great! Actually I have found it. It is 7.

     Silly: No Way? How did you guess?

Bubbly: La lala lalalalalala....

Okay, So as you can see, that was fast.

What Bubbly did was the efficient use of Binary search algorithm.

Here's a snapshot of what was going on in Bubbly's head:




Instead of looking through each element of an array linearly, binary search leverages the knowledge that the array is sorted and looks for the desired item by comparing it with the element at the middle of the array. If the element matches, all good, otherwise, we can simply ignore half of the array based on whether the number we want is greater or smaller than the one at the middle of array. This is efficient because, after each comparison, we are eliminating half of the comparisons that we would have done if it were a linear search.

Which means, if we are sorting a considerably large array, insertion sort can be made even faster by doing a binary search when searching for the ideal position for next element in array. The only thing that we need to consider is, mostly the element we are searching won't be present in the partially sorted array and hence, instead of saying that the element was not found, our search should return the position where it would have ideally been found. And in case of a non existent element, that will happen when we reach the array of size 1.

Such an insertion sort algorithm that uses binary search to search for an ideal position for each element while searching is called binary insertion sort.

I hope this gave you a clear idea of how Binary search helped us achieve a search algorithm which is slightly faster than the plane old insertion sort.

As usual, comments/appreciation/criticism (a constructive one of course) everything is most welcome and appreciated.

Until then,
Happy Learning!
Banyan Bat

Saturday, September 24, 2016

Killing the Loop in a Link

In the last post we discussed a way to find the loop in a link. Once we know that there is a loop in our linked list, first thing we should do if we want our linked list to be realistic and usable, is to remove the loop.

How do we kill the beast? I guess if we know where the loop starts, we will be able to burn its tell (set the next pointer of the magic node to null).

Lets get started.

What we already know? 

From our little stint in the last post in this category, we know for sure that there is a loop in the below linked list.
Linked List with a Loop
We also have our hare and tortoise pointers pointing to an element inside the loop. Like so.


As the hare and tortoise story goes, the hare stops in between the race thinking that the tortoise can never catch or overtake him. Eventually the tortoise through its sheer perseverance catches hare, overtakes him and wins the race. Nice inspirational story.

In our case, the ends don't meet as we don't have an end to our linked list. And by the way, our hare has read that story and thus he never stops. Which means he will continue to loop crossing the tortoise again and again until we let him stop. Which also means that at this point when both hare and tortoise are pointing to the same node, if we let our hare run and at each node increment loopsize by 1, by the time hare catches tortoise back, we will have the size of our loop.


What we already know? Update 1.
  • That there is a loop in our linked list.
  • And the size of the loop (in this case 4). 
Now lets start at the beginning again. Set hare and tortoise both to point to the start of the linked list and then give our hare a heads up of exactly the loopsize. (Yeah, this time no matter what, we will let our hare win the race. Why should tortoise have all the fun?). This makes hare and tortoise loopsize apart - make a mental note of it, this will come handy.

What we already know? Update 2.
  • That there is a loop in our linked list
  • The size of the loop
  • And two pointers one pointing at the start of the linked list and another loopsize away from it.
Now advance both hare and tortoise exactly by one node until both point to the same node at which point, tortoise will be at the start of the loop and hare will be at the end of the loop. And yeah, its a loop so both start and end are same :). Also while you are advancing the hare pointer, keep track of the previous value, something like this:
previous = hare;
hare = hare.next;


What we already know? Update 3.
  • That there is a loop in our linked list
  • The size of the loop
  • The start of the loop.
  • The Element at the end of the loop that points back to start.
Now killing this loop is simple. As I said earlier, just burn the tail. Okay, in technical terms, doing something like previous.next = null (removing the red pointer in the above figure); should do the trick. Here's our final linked list without a loop in it.


I hope you enjoyed this post. And I was able to express the algorithm in a way that will stick to your grey matter.

As usual, comments/appreciation/criticism (a constructive one of course) everything is most welcome and appreciated.

Until then,
Happy Learning!
Banyan Bat

P.S.

After successfully understanding the above algorithm to find and eliminate a loop in a linked list, you have an important and very handy tool under your belt sometimes referred to as a Two Pointer Algorithm. This algorithm can be easily used in a lot of other problems. One such example is:
  • Find Nth node from the end of the linked list.
I would like to leave you with the problem to find a solution. You can google for a ready made algorithm to solve this problem, but if you think on the grounds of what we just discussed in the last two posts, it might stick around your head a bit longer.

Also, this post pretty much concludes our discussions related to the singly linked list data structure. Although we will come back to the topic as and when it feels like a right thing to do :).

Friday, August 19, 2016

Dejavu : Finding a loop in a link


The linked list data structure we discussed in my last post in this category is really nice for sequential data. Insertion and deletion is also nice and simple. There is one problem though. If you want to go to the nth node in the linked list, you have to start from the first node and move one node at a time to your node. What if your node is the last node? You will have to start from the first node and traverse the entire list to get to your node.

Suppose you have the following linked list at hand and you want to go to the node Museum which is the last node. You will have to traverse through the entire list before you can get to it.
A simple Linked List
Okay, I know you love The link so much that you are ready to compromise and are OK with this tedious traversal. But the problem doesn't end there.

Me: Consider the following list. Try traversing through it.
Linked List with a Loop
The Link Fan: What's the big deal here? Here I go: Chocolate, Apple, Table, Shoe, Museum, Apple, Table, Shoe, Museum, Apple. Hold on, I feel like I have been here before, I can feel the word Apple coming again. Is it Dejavu?

Me: My friend, you are not in a Matrix and this isn't Dejavu. What you are feeling is a cycle (or a loop) in a linked list. And you were able to notice it because you are Neo, the one or at least a human, if that gives you any pride. But The Matrix (a computer program of-course) will not be able to detect this cycle and will continue to traverse through this list until it runs out of its resources (Only if Neo new this trick, he could have broke the Matrix in no time and there would not have been a need for all that machine war).

Is that what you want? Of-course not. Not in the real world not of The Wachowski brothers.

Then we must find a way to detect this cycle thingy and if possible, a way to get rid of it.

So lets first try to detect the loop.
  • Let's start simple, if the link is empty, it cannot have a loop. So we are good there.
  • If there is only one node which points back to start, you know that there is a loop.
  • Now if there are more nodes, we need something to detect a loop.
We will use an algorithm called a "Two pointers algorithm". This is also called a "Hare and tortoise Algorithm" because one of the pointers is slow while the other one is fast.

So lets get started, if there are two or more nodes, start the tortoise pointer at the first node and the hare pointer at the second node. Now we will continuously advance the tortoise pointer by 1 node and the hare pointer by two nodes (You see? Hare is faster than the tortoise).

If there is a loop in our linked list, at one time both the hare and the tortoise will point to the same node (In the real Hare and Tortoise story, the hare stops and rests because he underestimates the tortoise. Our hare here is honest as god, it will loop indefinitely if you don't ask it to stop. So, unless there is a loop, our hare and tortoise will never cross each other.). If that happens, you can be sure that there is a loop in your linked list and terminate the traversal.

If there is no loop in the linked list, the hare will eventually point to the end of the link(hare = null) or in case where there are even number of nodes in the linked list, you would not be able to complete the step hare = hare.next.next because hare.next is null (in other words, you would not be able to advance hare by 2 nodes because there is only one node before you hit the end of linked list).

To try the above scenario, remove museum node from the above linked list without a loop.  The hare can only be advance once(when it points to shoe) before hare.next is null.

Lets see if that works:

In our linked list with Dejavu, the hare and tortoise will have following stages during their traversal.
Tortoise and Hare on loop
If we remove the loop and run our algorithm (Linked list with odd number of nodes), it works something like this:
Tortoise and Hare on a straight highway
So this is how you find a loop in the linked list so that you can avoid running out of resources while traversing through a list that never ends.

I hope you enjoyed this post. And I was able to express the algorithm in a way that will stick to your grey matter. Also, do let me know if you think there is a better solution to this problem.

As usual, comments/appreciation/criticism (a constructive one of course) everything is most welcome and appreciated.

In the next post, we will discuss how to get rid of this loop. 

Until then,
Happy Learning!
Banyan Bat

Wednesday, August 17, 2016

Trick to an easy knot to an inflated balloon

As I told in my last post, I was attending a birthday party for one of my friend's daughter. It was a friend's daughter's birthday, so this uncle had to do something to help the overworked father complete the necessary arrangements. So, I chose the simplest of the tasks, well I thought so. Inflating balloons!! You would say, its not that easy, you have to exhaust your lungs. Haha... I am smart. I had already noticed that he had the pump to do that job, so I thought it would be fun. But I missed one important part. The inflated balloon needs to be tied so that it does not loose its air. How could I miss that? And (not so) surprisingly I was worst in doing that until that day.

So I shared my misery with my friend engaged in the same endeavour of helping the overworked father. Luckily he knew just how to do that. He courteously shared the steps with me and helped me learn it too. Thanks to him, it was a joy to inflate those balloons and tie knots on them.

Here are the steps for people like me (unless you all know it very well). Steps courtesy: The Friend: Rahul.

Step 1: Inflate the balloon using a pump or your own lung capacity. Make sure you don't blow it to explosion (Trust me, it happens. We exploded a bunch of them :) and we kinda loved it.).


Step 2: Hold the balloon in your left hand like so. Notice the index finger and thumb pointing up.



Step 3: Pull the open end of the balloon as far as you can safely holding it with index finger and thumb of your right hand.


Step 4: Now, pushing the balloon down with the three fingers of your right hand, push the stretched end of the balloon from above the balloon besides/along with the index finger of your left hand as shown in the pictures below. (Forgive me if I could not put it in words correctly. Believe me, I tried real hard.)




Step 5: Now, pull the open end of balloon slowly taking the index finger of your left hand out. The smooth and shiny nails really come in handy here.




And here's your inflated balloon with its knot tied securely.



Do let me know what do you think about these steps and let me know if these instructions could have been better.

As usual, comments/appreciation/criticism(a constructive one of course) everything is most welcome and appreciated.

Until then,
Happy Learning!
Banyan Bat