Serializing & Deserializing Binary Tree

We are going to serialize a binary tree to an array, A binary tree is a tree data structure. Each node can have 0-2 children(s). visualization of a binary tree 2 / \ / \ / \ 1 3 / \ / \ 0 7 9 1 / / \ / \ 2 1 0 8 8 Representation of a Node A node should contain the data(value) and reference to child nodes. A simple class like Node below will work for us. ...

December 9, 2021 · 4 min · Zeeshan Khan
A Man Invoicing

Serverless Invoice Generation

One of my non-techie friends was starting a new business and he wanted an Invoicing System. he reached out to me hoping that I can help him with a small website or app Open Source Software to rescue If this was me a couple of years earlier I would have started the typical Software Development Life Cycle for a new project, but this new me is lazy. So, I searched the web to find a decent open-source project that can fulfil his needs for now, I came across this project it looked very interesting to me, it was using LaTeX to generate the invoice since I had no experience in the tools I refrained to use it (although I would love to explore it). after going through a couple of interesting looking projects, I found something familiar ...

November 28, 2021 · 2 min · Zeeshan Khan
Conky Desktop

Conky - Lightweight System Monitor

I use ubuntu as my daily driver so all the commands are going to be ubuntu/debian based Installation Install conky-all package by sudo apt-get install conky-all Setup conky takes a config file to know what to draw on screen. the default location of config file is ~/.conkyrc Run you can start the conky by just typing conky in terminal, and a and ugly black window should come up. Customization There are thousands of options to pick conky config, and if that’s not enough you can just google for more. I’ll add a link to my favorites one here, Conky Orange its 11 years old still looks decent ...

November 27, 2021 · 2 min · Zeeshan Khan

Understanding Linux load average

>>> uptime 09:20:04 up 13:22, 5 users, load average: 0.11, 0.31, 0.42 Load average is those three numbers. It gives an idea about how busy the system is. It shows load for last 1, 5 and 15 mins, A common misconception is that it just shows how business of the CPU. It also considers other IO operations. Read the post below that explains when and how it is the way it is. ...

November 26, 2021 · 1 min · Zeeshan Khan

Factorial in C using Character array

Hey Guys, wondering why I am here once again with this “factorial” thing? You will get to know it in no time..just keep reading! Let’s calculate some of the factorials: 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 6! = 720 ...

June 15, 2016 · 5 min · Swati Kesarwani

Factorial in C

Hey! Today i am gonna show you how to calculate factorial of a number. The code below depicts the basic methodology of how to calculate factorial of a number. # include<stdio.h> void factorial(int number){ int i; long long int factorial=1; for ( i = number ; i > 0 ; i-- ) factorial*=i; // Printing the factorial of the number **/ printf("Factorial of %d = %lld",number,factorial); return 0; } int main(){ // Declaring variables **/ int num; // Asking and scanning input **/ printf("Enter a number : "); scanf("%d",&num); // Passing number to the function **/ factorial(num); return 0; } output of above code will be ...

June 1, 2016 · 1 min · Swati Kesarwani

Linked List in C

First let’s get familiar with some basic terminologies used in linked list. A linked list is a type of array in which each elements points to the next element. Each element in the list is called a node The very first node of the list is called the root node or head of the list. Linked list is represented only by the root node i.e., we store only the pointer to the root node. Memory for each node is dynamically allocated using malloc() or calloc() function from stdlib.h header file. Allocated memory should be released after use, using free() function. Now let’s look at the code below, although the code is self explanatory we will explain each portion separately. ...

November 23, 2015 · 8 min · Zeeshan Khan

How To Scan Input In Java

The best way to scan input in java includes the use of BufferedReader class, another method uses Scanner class but is slower, so here we will prefer BufferedReader. The following code demonstrate the use of BufferedReader for scanning input of different type. // file ScanInput.java import java.io.*; public class ScanInput{ public static void main(String args[]) throws IOException{ BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.print("Enter a String: "); String msg=br.readLine(); System.out.print("Enter a Integer: "); int integer=Integer.parseInt(br.readLine()); System.out.print("Enter a Decimal Number: "); Float float_number=Float.parseFloat(br.readLine()); System.out.println("String you entered is:"+msg); System.out.println("Integer you entered is:"+integer); System.out.println("Decimal Number you entered is:"+float_number); } } output is ...

February 3, 2015 · 1 min · Zeeshan Khan

Faster Input Scan Method in C

Sometimes we need to scan input really fast like when we are participating in coding competitions like codechef or SPOJ where the time limit is very strict and inputs are large, we can save some time by adopting faster scanning methods. We can achieve our gaol using getchar_unlocked function. code below scans 100000 integers and has two different methods one is scan_normal() this will scan integers using standard scanf() function and the other one is scan_fast() this scan integers using getchar_unlocked function, we will execute the program twice one for each method mark the time taken for execution to evaluate the performance. ...

January 26, 2015 · 2 min · Zeeshan Khan

How To Run a Java Program

To run a java program you must have one, so lets have a sample code which prints “Hello world!!” to console. Source Code If you have source code ready then ignore else create a new file Hello.java and copy the below code in it and save it. Source code // file Hello.java import java.io.*; class Hello{ public static void main(String args[]){ System.out.println("Hello World!!"); } } now you have your source code ready, ...

January 24, 2015 · 1 min · Zeeshan Khan