Posts

Showing posts from September, 2025

Learning MergeSort with JS

  Today I learn MergeSort in JS! I Learned mergeSort because this is the fastest sorting algorithm, as it takes O(n log n) time, which is better than bubble sort with time complexity O(n^2). At the end, I understood the main logic of MergeSort, the divide-and-conquer method. which means an array pass to merge_sort(arr), it starts by dividing into subarrays until it reaches 1 element of subarray, then it starts sorting it .  merge-sort.js function merge_sort(arr, l = 0 , h = arr.length - 1 ) {         if (l >= h) return     let m = Math. floor ((l + h) / 2 )     merge_sort (arr, l, m)     merge_sort (arr, m + 1 , h)     merge (arr, l, m, h) } function merge(arr, l, m, h) {         const tmp = []     let i = l, j = m + 1     while (i <= m && j <= h) {         if (arr[i] < arr[j]) tmp. push (arr[i ++ ])       ...

C linking with Masm64

  Today I learn Masm64 basics and linking with C Modules day 9/19/2025: Today I learn MASM64 basics and linking with a C program. Now I  am a very basic MASM and C programmer, so it was hard for me to create my own printf in MASM. Then an idea came to my mind to link C printf with Masm. To achieve this desire, I created a new program in C named practical.c and practical.asm. After spending hours, I am successful in achieving this. Then, I want to get user input in ASM, as previously I said, this was also hard for me to take input in MASM, so I created a readLine function in this function takes a buffer and maxLen from MASM and gets input, and prints. practical.c /*     Author Danishk Sinha */ #include <stdio.h> #include <string.h> #include <stdlib.h> #include <stddef.h> #ifdef __cplusplus extern "C" { #endif char * getTitle ( void ); int readLine ( char * buff, int len); void asmMain ( void ); #ifdef __cplusplus }; #endif int rea...