My elder brother needed an application to manage price lists of his wholesalers and dealers. Products’ prices that he is following are subject to change daily because exchange rates may change daily and it may be very hard to find optimal price for a product if it can be obtained from multiple dealers. So I decided to help him with an software solution. Price lists and displays support utf-8 (as they can be seen in screenshots – Russian language price lists are used for tests).
If you tried to run your android app on your device and android studio shows that device off-line there are some reasons:
- You may be using and USB3.0 port, move it to USB2.0
- Your USB cable may have some problems, change it
- Restart phone, adb etc.
First option solved mine.
In this post I will provide mathematical background and C++ implementation of greatest common divisor (GCD) calculation of big numbers problem. Problem can be described as:
You have two numbers to calculate their GCD. First number is very big, let say 250 digits long. Other number is not so long, maybe less than 6 digits. How do you calculate GCD of these two numbers. Continue reading
Selection sort finds minimum element of the unsorted elements and swaps it with the first element of unsorted part. It continues with the rest of the unsorted elements with this manner. Below is the implementation of selection sort. Note its worst case is O(n^2). Continue reading
Merge sort is a divide and conquer based algorithm. Its merge behavior names the algorithm. Algorithm details can be found elsewhere but I’ll give my basic merge-sort implementation here. It starts with dividing the array into two equal sized arrays. Division done until each array only holds an element. But merging procedure is the interesting part of the merge array. It merges 2 arrays into one sorted array. Continue reading
Quick sort is a divide and conquer based algorithm like merge sort. I provide my implementation of quick sort which is implemented recursively. Continue reading
Breath First Search and Depth First Search are two graph traversal algorithm to search graph items. I provide my implementation for both methods. Code is self explanatory. I also provided a simple graph implementation. Continue reading
This is like a puzzle question: you iterate the list but at the end of the iteration (i.e. when you reach the end of linked list) you should display the half. The question seams hard because you do not know how many node exist in the list. So, how you find the half when you reach at the tail. One solution may be to store all elements into an array, but this is quite inefficient and possibly infeasible way to solve this question.
My proposed solution is:
- Traverse the list with double next, this is iterating the list with node->next->next
- Hold another pointer for half of the list. While iterating double next half of the list pointer iterates with one next.
I added the code for a simple list (supports addition to head, and tail – I did not test the tail :). Continue reading
Binary Tree is very famous data structure. Left of the parent node has smaller than parent’s value and right is bigger. In this code I’ll give a simple demonstration of binary tree (implemented in C++ but knowing C is enough to get the idea). Although code is self explanatory I’ll give important highlights. Continue reading
Ok, even though this can be done with many other methods, I’ll explain mine. I’ll also provide youtube videos for the procedure and demonstration as well.
Unlike offline backups, online backups require minimalist suspend – save – resume actions (hopefully within small amount of time – which depends your modifications and RAM usage) while taking the snapshot. The requirement for this suspend has similar reasons to live migration –state is hold and saved then it continues to execute.
As described in our offline backups post, we could take internal or external backups. But in this post we’ll discuss external backups particularly to take backups.