Sunday, October 23, 2016

Why pay 3000 times more?

Did you ever feel that we spent lot more money for a SMS? Sri Lankan mobile network providers charge only 10 cents for a SMS. One SMS contains 160 characters which each character is 7 bits. There are 1280 bits in a sms. Cost for a bit in SMS is 0.000078125 cent per bit. Story is not finished. 1MB of internet data is .20 cents. Cost for a bit in internet is .00000000238 cent per bit. SMS costs 3285 times than if we send that same SMS through internet. If we concern this fact to a telephone call, the situation is worse. I think there no need to doubt about IDD calls.
So why we pay more? We have to pay because there are no other options? This may be the typical answer of a Sri Lankan. But if we asked the same question from a American his answer will be different. They do not use SMSs and Telephone calls anymore. Viber, Whatsapp, Imo and messenger melted the dominance of SMS and telephone calls.
Popular communication apps now a days
WhatsApp started as a texting service between mobile phones as a replacement for the regular SMS text messages. But now it provides internet call facilities as well. VIber and messenger provides texting and internet calling while imo provides video calling as well.

imo - caters video calling facility
Even though it is cost effective why its not popular in Sri Lanka? There are many reasons. One is most of the mobile users are not powered with smart phones. Viber, whatsapp, imo, messenger only supports for smart phones.

Messenger User Interface
Even the smart phone users do not have a habit to keep internet switched on. They switched internet off to preserve the battery. To take a viber call or to send sms via whatsapp in a real time manner both sender and receiver has to logged in to the internet.

How to preserve the Battery???
Sri Lankan mobile network providers do not provide satisfactory internet service. In some areas of Sri Lanka there are no 3g internet facilities. To get the maximum privilege form viber and whatsapp you should have proper internet connection.

Internationally telephone calls and SMSs already dominated by Viber and Whatsapp. In Sri Lanka also using Viber and whatsapp becoming a trend. So in near future we will be able to say good bye to traditional Telephone calls and SMSs and welcome Viber and whatsapp.


Sunday, June 19, 2016

Binary Search Trees - BST (C++ implementaion)

Hi Guys,

Our final year just started. For my seventh semester I follow "Advanced Algorithm" Module. For the second day we were taught various of trees which were inspired by Binary Search Trees. You know when it comes to algorithms, all are not straight forward at all. Even though the theories are explained in pseudo codes, sometimes some of the steps are tricky. That because we are much familiar with the programming language which we use at most of the times.

Okay, the problem started like this. Before to study the tree concepts inspired by BST (here after Binary Search Tree will be called BST), I must have a thorough knowledge in BST, right :D ? But I can't remember a thing. So I started studying BST but pseudo codes were not straight forward and reading theory made me boring. Then I started to refer already implemented codes. But most of them were deviated form the pseudo code. So I dusted my hands and started to implement BST Operation based in Pseudo codes.

I preferred C++ and I implemented the code in C++.  You can view it as a code blocks project in this link Code Blocks Project .

What is Binary Search Tree?

BST is organized as a binary tree with the following properties.

Let x and y be nodes in a BST
• If  y is in the left subtree of x, y.key ≤ x.key
• If  y is in the right subtree of x, y.key ≥ x.key

There are key words related with BST, They are,


  • Root - The First Node of the tree
  • Leaf - The endings of the tree are called leaves (leaf). They don't have any child nodes.
  • Height of a node - Number of edges along the longest path from the node to a leaf.
  • Height of Tree - Simply the height of the root. Descriptively Number of edges along the longest path from the root to a leaf.
  • Depth of node : Number of edges from the root to the node 


Let's implement it :)

Node :
Binary Search Tree Node represents the element of BST. It contains a key value, pointer to left child, pointer to right child and pointer to its parent. Following is the implementation of a node in C++.

struct node{
    int key;
    node *left;
    node *right;
    node *parent;
};

Tree :
Tree holds a pointer to the root node. If this root node is null, it means the tree is empty. Following is the implementation of a BST in C++.

struct BST{
    node *root;
};

INSERTION IN BST !
Let us insert some values to the tree. 

The Basic rule of BST is,

Let x and y be nodes in a BST
• If  y is in the left subtree of x, y.key ≤ x.key
• If  y is in the right subtree of x, y.key ≥ x.key





For the ease of learning, we will consider this order of keys entered to the BST.

10, 2, 20, 6, 8, 5, 14, 23, 4 , 3, 1



So if we followed binary search properties well, the expected output tree should be,


So now let's discuss step by step, how inserted them.


First thing BST Insertion is, we always start from the beginning. The first node is 10, then it will be the root.

In Step 1, 2 is smaller than 10, so 2 will be the left child of 10.

Step 2 : 20 is greater than 10, so 20 will be the right child of 10.

Step 3 : 6 is smaller than 10, it should be in left side of 10. But 10's left child is occupied. So it will forward to 10's left child which is 2. Now ^ is greater than 2. So 6 will be 2's right child.

Step 4 :  .........

Step 5 : 23 is greater than 10. It should be in right side of 10. 10's right child is occupied. It will forward to 10's right child which 20. 23 is greater than 20. So 23 will be 20's right child.

Step 6: 1 is the smallest among all of them. It should be in 10's left side, So it will be the 2's left child.

Following is the implementation of the node insertion in BST in C++ .

void BST_Insert(BST *T, node *z){

    node *y = NULL;
    node *x = T->root;

    while(x != NULL){
        y = x;
        if(z->key < x->key){
            x = x->left;
        }
        else x = x->right;
    }
    z->parent = y;
    if(y == NULL){
        T->root = z; //tree T is empty
    }
    else if z->key < y->key ){
        y->left = z;
    }
    else{
        y->right = z;
    }
}

Please find a simillar kind of example in this link.

TRAVERSE THROUGH BST!

In early we discussed that, when we consider a node in BST, left child contains the smaller key value than the key of node and right child contains the larger key value. Using this basic idea we can going around the BST in a sorted manner. In this algorithm we use Recursion .

The implementation of the algorithm as follows in C++.

void IN_ORDER_TREE_WALK(node *root){
    if(root != NULL){
        IN_ORDER_TREE_WALK(root->left);
        cout << root->key << endl;
        IN_ORDER_TREE_WALK(root->right);
    }
}

For our given order the In Order Traversing result should be,




This may harder to understand, but let us clear this algorithm implementation with our example.


Following diagram shows the execution order of the recursive algorithm. If you don't understanding the following algorithm, I suggest you to improve your knowledge in recursion because in these typ of tree structures, recursion is heavily in use.


Today we learnt, What is a BST, how to implement a node and a BST and insertion and in order traversal in BST.

In Next Article, we'll discuss Finding the successor, find minimum key of a BST, find the maximum key of BST and Deleting a node in BST. Anyway I have already implemented them in the project. You can refer them and get a good idea of its implementation. Till then good bye.

Link to the Code Blocks C++ Project

Please feel free to publish problems in the comments and I will help you if I can :)

Monday, May 30, 2016

Internship @ OrangeHRM

Hey Peeps :) . In the introduction, I said that I am a final year student. In our faculty, we have to complete a 24 weeks internship program in an established and reputed company. So I did an internship which is undoubtedly the "Best Place for an internship". The place is OrangeHRM Inc. (link to site) .

Before sharing my internship experience, I would like to tell you a little but about the company :) . OrangeHRM HRIS was initially a one of the products implemented by hSenid Software International. Initial development work was done by two interns at hSenid at that time. Later this product was highlighted as a good marketable product. Later this product was separated from hSenid and OrangeHRM was formalized as a seperated company. 

CEO of OrangeHRM Mr. Sujee Saparamadu is the brother of Dinesh Saparamadu, CEO of hSenid Software International. It was started with five employees. Its first Open Source version was released in 3rd of February, 2006. From its first launch, it was acclaimed as a good and comprehensive HRIS product. It had the capability of fulfilling most of the HR requirement. After the ten years time OrangeHRM increased its clientele day by day and was awarded in numerous awards like BOSSIE Awards and it was ranked at 4th in Topmost Popular Enterprise Solution by sourcefourge.net.

Ok, let's talk about the pathway of getting selected as an Software Engineer Intern at OrangeHRM. It was not that easy and also it was not that hard. Recruitment process includes an interview, a written exam in IQ and a written exam in Algorithms. Five of students from our university were called for the interview. But two of us were selected including me :) .

I was interviewed by Mr. Thilanka Kaushalya (Senior Tech Lead) , Mr. Nirmal Wijesinghe (then Associate Tech Lead, now Associate project Lead) and Mr. Buddhika Gunathilake (Associate Tech Lead). Even though this interview was to hire an intern, it seemed that they took this job serious. Because it took one hour and 15 minutes to finish my interview. Later I sat for the IQ and Algorithm Tests and after two days it was confirmed that I was hired as a Software Engineer - Intern.

I must say, the learning experience which I gained from there was awesome. I will share the work experience and learning environment of at OrangeHRM , in another post. 

One of the best things in OrangeHRM is the friendly working environment. No matter how senior the person, they treat new recruits like us as their friends and they are always there for our help. The next best thing is OrangeHRM believes in us even we are interns. That made us responsible persons and put some thinking to the work which prevented us from blindly following the protocol. 



Apart from work, there were plenty of fun events we could enjoy. They were English Forum, Dinner Outs, Movie Nights and many more. 




I will share the work experience I've got from OrangeHRM internship in another post. Let us Wish very good luck to OrangeHRM Inc.

Welcome to YasSpace

Hi all. I am Yasanka Jayawardane. I am a Sri Lankan and I am from Bandarawela. Currently I am a final year student of Department of Computer Science and Engineering, Faculty of Engineering in University of Moratuwa. I am 25 years old.

Blogging is not a new thing to me. I maintained a blog called  "නිමිත්ත" which means "Cause". In that blog, I published poems written by me. The specialty of my "නිමිත්ත" blog is, I publish both poem and the cause of writing that poem. Sometimes it lead to arguments as readers may not agreed with my cause and the poem.

Anyway, the reason behind coming up with this YasSpace is to share my experiences and learning I had in my university life. Mostly I will share the knowledge I will gain from the final year project (FYP) as it will make easier to spread out the news of our projects.

Thank you very much and stay connected with me because lots of new and interesting articles yet to be released.

Cheers (Y)


Yeah, this is me :D