Price List Application (Flask, SQLAlchemy, pyQT4)

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 … Continue reading Price List Application (Flask, SQLAlchemy, pyQT4)

Greatest Common Divisor (GCD) of Big Numbers – A Recursive Approach (C++)

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 … Continue reading Greatest Common Divisor (GCD) of Big Numbers – A Recursive Approach (C++)

Selection Sort

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). #include <iostream> using namespace std; int find_min(int* arr, size_t size, int … Continue reading Selection Sort

Merge Sort

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 … Continue reading Merge Sort

Quick Sort

Quick sort is a divide and conquer based algorithm like merge sort. I provide my implementation of quick sort which is implemented recursively. #include <iostream> #include <cstring> using namespace std; void display(int* arr, size_t size) { for (int i = 0; i < size; ++i) { cout << arr[i] << endl; } } int partition(int … Continue reading Quick Sort

Breath First Search & Depth First Search

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. #include <iostream> #include <vector> #include <algorithm> #include <stack> #include <queue> using namespace std; struct Vertex { char name; int number; Vertex(): … Continue reading Breath First Search & Depth First Search