Posts

Computer Algorithms - Stacks and Queues

Image
1. Data Structures Computer programs store large amounts of data, retrieve it in the required order, and process it. A data structure is a structure that defines how data is stored and managed. Data structures are fundamental tools for implementing algorithms. If an algorithm is a procedure for solving a problem, a data structure is the method for holding and organizing data during that process. Even with the same algorithm, processing speed and implementation details can vary depending on which data structure is used. 1.1. Stacks and Queues Stacks and queues are linear data structures that store and retrieve data in order. A linear data structure is a structure in which data has an order, as if it were connected in a single line. Stacks and queues are among the most basic linear data structures and form the foundation for many data structures and algorithms. 2. Stack A stack is a data structure shaped li...

What Is a Computer Algorithm?

Image
1. Algorithm 1.1. Origin of the Algorithm The term algorithm comes from the name of the 9th-century Persian mathematician Muhammad ibn Musa Al-Khwarizmi (Muhammadibn Musa Al-Khwarizm). He wrote one of the earliest Persian mathematics books and systematically organized arithmetic operations such as addition, subtraction, multiplication, and division based on Arabic numerals introduced from India. As his name was rendered in Latin as Algorismus, the word algorithm , meaning a method or procedure for calculation, was created. Statue of Muhammad ibn Musa Al-Khwarizmi in Urgench, Uzbekistan - [Source] majalla.com 1.2. What Is an Algorithm? An algorithm means a defined procedure and method for solving a problem . It can be compared to a cooking recipe, but an algorithm differs in that every process must be logically and technically defined with c...

C Language – Code Analysis Practice (Intermediate Examples)

1. Intermediate C Code Analysis Examples 1.1. Pointer Size and String Length Understand how a character pointer that points to a string literal behaves. Confirm that sizeof and strlen calculate values using different criteria . #include <stdio.h> #include <string.h> int main ( void ) { char * text = " 0123456789 " ; size_t result = sizeof (text) + strlen (text); printf ( "%zu\n" , result); return 0 ; } char *text is not an array that stores the string contents; it is a pointer that stores the starting address of a string literal. sizeof(text) is the size of the pointer variable itself, which is different from the length of the string it points to. strlen(text) counts the number of characters from the location the pointer references until it reaches '\0' . The size of a pointer can vary depending on the execution environment, and this explanation uses a 64-bit environment as its basis. 1.2. Poi...

C Language – Function Arguments Using Pointers

Image
1. Function Arguments in C Programming languages pass function arguments using either Call by Value or Call by Reference .  However, in C, function arguments are always passed by Call by Value .  In other words, the value passed to a function is a  copy , so the function cannot directly access the original variable. For this reason, C achieves a Call by Reference effect by using pointers to pass a variable's address as a value. 1.1. Function Argument Passing Methods Method What is passed Can change original Call by value The variable's value No Call by reference The variable's  address Yes 1.1.1. Call by Value Call by Value is a method that  passes a copy of the value to the function . Therefore, even if the value is changed inside the function, the original variable is not affected. 1.1.2. Call by Reference Call by Reference is a method that uses a pointer to...