In this episode of “Did you know..?” we look at some C language tips.
- scanf() wrong format for an operand
- Array size and starting index
- Wrong use: = instead of ==
- scanf() forgetting the ampersand (&)
More »
Posted in Programming Tips |
Exclusive-OR (XOR) encryption is an encryption method that is hard to break through with so called “brute force” methods (brute force = using random encryption keys in the hope you find the correct one.), but the encryption method is susceptible to pattern recognition. Patterns can be easily avoided by first compressing the file (compression already makes it unreadable, it removes patterns for you) before it is encrypted. More »
Posted in Programming Algorithms |
An inventor called DL Shell came up with a very interesting sort which he called shell sort. This sorting algorithm is almost similar to the bubble sort algorithm. The shell sort compares elements that are a certain distance away (d positions away) from each other and it compares these elements repeatedly (bubble sort only compares adjacent elements.) It uses the equation d = (n + 1) / 2. More »
Posted in Programming Algorithms |
The insertion sort only passes through the array once. Therefore it is a very fast and efficient sorting algorithm with small arrays. (The efficiency is lost however with large amounts of data.)
The sort works as follows: the array is split into two (virtual) sub-arrays. (With virtual I mean that the array is not really split.) The first sub-array is considered to be the “sorted array”. The elements of the second sub-array will be inserted into the first sub-array at the right position. More »
Posted in Programming Algorithms |
The selection sort is using a combination of searching and sorting. Each unsorted element that has the smallest or largest value is moved to the proper position.
The inner loop (see the example) is used for the selection and this loop is searching for the smallest or largest value.
The outer loop is used for putting that value into its proper position. More »
Posted in Programming Algorithms |
The exchange sort is almost similar as the bubble sort. In fact some people refer to the exchange sort as just a different bubble sort. (When they see the source they even call it a bubble sort instead of its real name exchange sort.)
The exchange sort compares each element of an array and swap those elements that are not in their proper position,
just like a bubble sort does. The only difference between the two sorting algorithms is the manner in which they compare the elements. More »
Posted in Programming Algorithms |
The bubble sort gets its name because as array elements are sorted they gradually “bubble” to their proper positions,
like bubbles rising in a glass of soda.
A bubble sort will compare two adjacent element of an array and will swap them if they are out of order.
The compare starts with the first and second element. After that it will compare the second with the third element and so on. The process continues until the end of the list is reached. More »
Posted in Programming Algorithms |
If you use a good naming convention in your source code then this can increase the readability tremendously.
In this tutorial we look at programming style and naming conventions which will increase the readability of the source code. More »
Posted in General Programming |
Every programmer knows that there are multiple ways to solve the same problem in a programming language like C or C++. This can be considered both a good or a bad thing. It is a good thing because you have the “flexibility” to solve the problem in different ways. More »
Posted in General Programming |
You can see if someone is a good programmer not only by the technical solution he/she chooses, but also by the programming style he/she uses in their programs. One of the hallmarks of having a good programming style is consistency and clarity. If the style is constant it is much easier to read and understand. More »
Posted in General Programming |