The C11 standard added a few new keywords to the language. These are often called the “underscore keywords” because each is prefixed with an underscore. The second letter is often capitalized, as is the case with _Alignof.
Continue reading
Searching a Binary Tree
As you might suspect, searching a binary search tree (BST) involves a recursive function. This function must plow through the tree, finding a value in a specific node. Because the BST is organized, the search process works far more quickly than when the data is unorganized or set in a sequential array. In fact, the bsearch() function uses a similar scheme requiring that the data first be sorted before the function works its magic.
Continue reading
Pick the Base – Solution
Your task for this month’s Exercise is to write a program that outputs a value in any base, between 2 and 10. Sure, you can use this code to communicate with alien species that use a base other than decimal, but this benefit is only a happy coincidence to the exercise.
Continue reading
Climbing the Binary Tree
A binary search tree works best when code is available to search the tree. Before doing so, I’d like to demonstrate how a tree is processed, one node at a time.
Continue reading
Pick the Base
Difficulty: ★ ★ ★ ☆
I watched the film Contact a few weeks ago. The movie is about first contact with an alien civilization. It’s smart cinema, which offers that communications between species would be mathematical in nature, as math is the universal language.
Continue reading
Planting a Binary Tree
Tree structures are yet another way to organize data. They’re similar to a linked list, but with the data organized by value into a series of branches and leaves. OMG! It’s like a tree!
Continue reading
Outputting a Table of Math Stuff
Though I’m admittedly not good at math (at least according to my grades in school), I enjoy playing with math stuff on the computer. Programming allows me to mess with numbers and values without the risk of that ugly red mark and the need to wonder how a D or an F on my transcript affects my overall GPA.
Continue reading
To #include or not to #include
I had a reader offer me a puzzle the other day. His code ran well without the #include directive and he wondered why. I did, too.
Continue reading
Numbers Complex and Imaginary
Your C programs aren’t meant to suffer with an inability to handle values such as the square root of -1, the imaginary number i. No, you can easily manage such mathematical mysteries, making rare the possibility of a -nan result, as shown in last week’s Lesson.
Continue reading
Formatting a Series for Output – Solution
The challenge for this month’s Exercise is to output a series of numbers, 1 through 10, and to ensure that the final number doesn’t look dorky. I’m certain that’s what I asked for.
Continue reading