C Programming and Computer Geeks: C Tutorials

Search MY Blog

Showing posts with label C Tutorials. Show all posts
Showing posts with label C Tutorials. Show all posts

Thursday 21 November 2013

Quick-sort Algorithm with Hungarian folk dance


Very good video on Quick sort Algorithm.This is the easy way to understand the Quick sort algorithm
useful video for learners/beginners in C Programming.




Concept of Quick Sort:
Quick sort is a divide and conquer algorithm. Quick sort first divides a large list into two smaller sub-lists: the low elements and the high elements. Quick sort can then recursively sort the sub-lists.


Quick Sort algorithm
Quick Sort



The quick sort algorithm works by partitioning the array to be sorted, then recursively sorting each partition. In Partition, one of the array elements is selected as a pivot value. Values smaller than the pivot value are placed to the left of the pivot, while larger values are placed to the right.
 
See the left side placed Quick sort animation for reference.

 

Follow My YouTube Channel on LTE @ Long Term Evolution/4G

Tuesday 11 June 2013

Bitwise shift operators

How do the bitwise shift operators work?


The bitwise shift operators take two operands: the first is a quantity to be shifted, and the second specifies the number of bit positions by which the first operand is to be shifted. The direction of the shift operation is controlled by the operator used. Shift operators convert their operands to 32 or 64 bits and return a result of the same type as the left operator.
Shift Operators
OperatorUseDescription
<<op1 << op2Shifts bits of op1 left by distance op2; fills with 0 bits on the right side
>>op1 >> op2Shifts bits of op1 right by distance op2; fills with highest (sign) bit on the left side
>>>op1 >>> op2Shifts bits of op1 right by distance op2; fills with 0 bits on the left side

Monday 10 June 2013

C Compilation Steps

C Compilation Steps


The above diagram shows the C Compilation steps.
STEP 1: Preprocessor
The main function of the C preprocessor is to remove comments from the source code and
interpret preprocessor directives which are given by the statements that begin with #. the preprocessor would strip the source of the comments contained
within the /*...*/ and would include the files assossiated with #include statement
and finally generates hello.i file

STEP 2:Compiler
Once the C preprocessor has stripped the source code of the comments and expanded the
preprocessor directives given by the lines that begin with # , the compiler translates the C
code into assembly language, which is a machine level code that contains instructions that
manipulate the memory and processor directly, in a layer beneath the operating system.
compiler is directly responsible for converting C syntax into this machine level code.
 And finally generates  hello.s 

STEP 3:Assembler
converts the machine-level instructions into binary code.
Assembler generates the objective file hello.o
The object file hello.o contains a binary version of the machine language

STEP 4:Linker/Link Editor
If a source file references library functions or functions defined in other source files the link editor combines these functions (with main()) to create an executable file. External Variable references resolved here also. 
means it will includes all the libraries,other Object files/Modules.

STEP 5: Loader
Makes use of binary format interpreter and process executable file header,it also determines the sizeof exe image.

coordinates with virtual memory subsystem and allocates Virtual memory address space required to load the program image.

Copies the exe image to virtual memory space allocated.

invokes process management sub system to process the registration of the exe.

Process management subsystem allocates a process control block(PCB) object and register a process

PCBs are linked up for CPU time from Scheduler.

A process once acquire CPU slice will start execution.


Search This Blog