Today I’d like to give codes and solution to reverse a singly linked list in a single pass and not using superfluous storage.
Off course there is a solution if you duplicate list, put all values into a vector or array, and other not efficient ways to accomplish this task. Recursive solutions could also be proposed. But iterative solution is the best way to solve this problem. Because if you use recursive method, there will be superfluous, and not necessary method calls and extra stack storage will be used for each local variables, and it won’t be best shot because if number of nodes in linked list is too much then you’ll probably exhaust your stack memory.
This is a puzzle like problem for linked lists. We’ll use similar solution for our code in Finding The Half Of Linked List in Single Traversal. But we’ll add some spice to the code in order to convert solution to be applied to this problem.
Ok let’s have a look to our proposed solution. Continue reading
Recently I’ve developed a brute force password cracker tool (can be found in post BruteForcer). I think it deserves to mention some design characteristics of the application. I’ll mention Alphabet Generation in other words base 26 operations that is used and needed for many programmers.
Alphabet to Generate
Our generator should output strings based on the alphabet that we provide. For instance if our alphabet was:
Alphabet = “ABC” Continue reading
I’m very forgetful these days. Even though I could not remember what I ate yesterday or what I wore, I have password protected everything. As a result, most of the times I have ended up with a locked zip, tar.gz or other file. Yesterday I had same experience and I decided to write a brute force python application to crack my password protected file.
Unfortunately I knew that it would take time for the app to crack with brute force technique, but I could use some tricks to improve performance. For instance I can limit the alphabet to attack (most of you use same pattern, special characters, password scheme for encryption) which would save time significantly.
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).
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