Current area: HOME -> C / C++ -> Data structures & Algorithms Articles
Data structures & Algorithms
A Checksum Algorithm
Historically, checksums have been used to increase data transmission reliability, whether from a serial line or network, tape drive, or disk drive, among the many data sources that require reliability checking. However, checksums have other uses, such as in dialog box change-state maintenance, docum
Balanced Binary Tree
This article give a brief, non-academic (=no dwelling into time complexity issues), explanation of what binary trees are about. It also provide source and demo of a generic tree class. Functionality to balance the tree is also described/provided.
Bits - Overview, Uses, Binary and Hexadecimal Numbers
Bits are the smallest units of information available in a computer. They are binary. That is, a bit has two states. It can be used to represent such concepts as true/false, yes/no, duck/rabbit and on/off. Bits are combined to form larger data types. For instance, a byte consists of 8 bits. As we will see, other data types are formed from larger combinations of bytes, and thus from bits.
C AVL Tree "Generic Package"
AVL Balanced Binary Search Tree "Generic Package" in ANSI C that interfaces to tree nodes as abstract data structures. Suitible for embedded systems or system/kernel level programming.
C++ AVL Tree Template
A C++ AVL Balanced Binary Search Tree template that interfaces to tree nodes as abstract data structures. Suitible for embedded systems and system/kernel level programming.
Coding generic lists of objects in C/C++
Have you ever had a project that required you to have an indeterminate number of different objects in memory? For some purposes a binary tree is the best solution, but usually the simpler linked list is the obvious choice.
Data Structures On C/C++
I have created this site to help students in Comp Science and
Information Technology to easily get programs which are usually
given in assignments, sessional exams lab tests as well as
University exams. Ihope u will be benefited a lot.
Delaunay Triangles
For one of my projects, I needed the so-called Delaunay triangulation of a set of points. Loosely put, the Delaunay triangulation is the most efficient way to draw triangles between pairs of points. Each point is connected by lines to its closest neighbours, in such a way that all line parts form triangles, and do not intersect otherwise. No triangles overlap; in fact, the surface is completely covered with one nice layer of different triangular tiles.
Dynamic memory with C++: Linked Lists
Arrays can be used to store a series of data when the members of the series is fixed or bounded. But if the length of array is to be decided in the run time, Linked list can be used. This article helps you to start programming with linked lists.
Everything To Know About C Types
The C type system is often misunderstood or overlooked. This article, the second in a series, discusses the derived types, or types that are built from other types, and some of the interactions that occur when data of multiple types are mixed. Part 1 introduces the basics of the C type system, with an overview of what it means to talk about type and a discussion of the basic types in some detail.
Everything You Ever Wanted to Know about C Types
How large is |char| on a 60-bit machine? What's a trap representation? How can |free()| change its argument into a null pointer? Learn about these questions and more in the third article in our series on C types.
Generic algorithms
Algorithms are at the core of computing. To be able to write an algorithm once and for all to work with any type of sequence makes your programs both simpler and safer.
Implementing associative arrays in C/C++
This article demonstrates using string/char* indexes in regular C array, e.g. myArray["age"]=10;
We usually use numaric indexes in arrays with C and C++. But there can be another way of using C / C++ arrays like in PHP.
Mastering Recursive Programming
Recursion is a tool not often used by imperative language developers, because it is thought to be slow and to waste space, but as the author demonstrates, there are several techniques that can be used to minimize or eliminate these problems. He introduces the concept of recursion and tackle recursive programming patterns, examining how they can be used to write provably correct programs.
Message Digests and Digital Fingerprints
A one-way hash function, also known as a message digest, takes an input string of arbitrary length and produces a fixed length hash. You could think of it as a digital fingerprint. It is generally thought that no two keys (e.g. pass phrases) can produce the same hash value. Therefore, when a one-way cryptographic hash is used as a password authentication method, it does not try to decrypt the hash and compare the resulting plain text but rather encrypt the user-supplied plain text (password), hash it, and then compare the hash values.
Portability and Pitfalls of C-Types
Ever wonder why the people who introduced Hungarian Notation now advocate against using it? This article takes a look at notation, programmer efficiency, and avoiding common mistakes. This is the final article in the Everything you ever wanted to know about "C types" series.
Programming in C++
C++ tutorial covering comp sci background, syntax, data types, operators, type conversion, logical expressions, control structures, formatting output, functions, pointers, arrays, array-type problems, user-defined types, header files, structures, enum types, graphics, classes, function/operator overloading, static variables, and much more. A must read for anyone learning C++.
Reconstruction of binary trees from traversals
The article is on binary tree reconstruction from a combination
of 2 Traversals of the binary tree. It also investigates why
some it does not work for some combinations such as preorder
and postorder traversals etc. It includes C codde for every
example presented.
Selecting a Geometrical Object
For the last year, I have been working on a project that involves a lot of 2D and 3D geometry. I needed some technique for the user to select these geometries easily, i.e. using the mouse and clicking. The biggest problem was determining how the program knew if the cursor was overlapping the geometry. For a while, I used basic boundary-based selection but found that this was not adequate and I was unable to use any API-based regions.
Sorting of numbers
Here is an article on sorting of numbers using
Selection sort, Bubble sort, Insertion sort. You could also download the program to see how the sorting process takes place. The program is written using C graphics.
Temporary Variables: Runtime rvalue Detection
In this final article in the series covering temporary variables, Jun Nakamura explains how you can test whether a variable is temporary or not, by using the ternary conditional operator.
Understanding C++ data types
This is part I of a short book for those beginners in C++ or even in programming who didnt understand data types in C++.
This book is meant to be a patch to other books, that cover the basics of C++. Because data types can be a little tricky sometimes, and difficult to understand, this book explains how data types work, and also shows you how to use them by giving examples.
Using the Observer Pattern to Update Dependent Objects
The Observer pattern defines a one-to-many dependency between objects--when the central object changes state, all its dependents objects are notified and updated automatically. Master this pattern and you won't have to worry about managing consistency of state between components.