Refers to the number of bits that can be processed or transmitted in parallel, or thenumber of bits used for single element in adata format. The term is often applied to thefollowing: microprocessor: indicates the width of theregisters. A 16-bit microprocessor can processdata and memory addresses that are representedby 16 bits. bus : indicates the …
Category Archives: computer science
Algorithms: bit manipulation
What is hashing ?
http://searchsqlserver.techtarget.com/definition/hashing
Project Euler Problem 2, solution internals related using ruby debugger
$ruby -rdebug euler-two.rb Debug.rb Emacs support available. /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:57: RUBYGEMS_ACTIVATION_MONITOR.enter (rdb:1) r /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:57: RUBYGEMS_ACTIVATION_MONITOR.enter (rdb:1) r /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:57: RUBYGEMS_ACTIVATION_MONITOR.enter (rdb:1) next /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:143: RUBYGEMS_ACTIVATION_MONITOR.exit (rdb:1) next euler-two.rb:3:n1, n2 = 1, 2 (rdb:1) next euler-two.rb:4:sum = 0 (rdb:1) print n1 1nil (rdb:1) print n2 2nil (rdb:1) next euler-two.rb:6:while n2 < 4000000 (rdb:1) print n2 2nil (rdb:1) next euler-two.rb:7:sum += …
Continue reading “Project Euler Problem 2, solution internals related using ruby debugger”
Project Euler Problem 3, solution internals using python debugger
$python -m pdb euler-three.py > /home/jeffrin/beautifulwork/lib/euler-three.py(7)() -> ”’ (Pdb) r 6857 –Return– > /home/jeffrin/beautifulwork/lib/euler-three.py(17)()->None -> print n (Pdb) next –Return– > (1)()->None (Pdb) next The program finished and will be restarted > /home/jeffrin/beautifulwork/lib/euler-three.py(7)() -> ”’ (Pdb) next > /home/jeffrin/beautifulwork/lib/euler-three.py(9)() -> n = 600851475143 (Pdb) next > /home/jeffrin/beautifulwork/lib/euler-three.py(11)() -> i = 2 (Pdb) next > /home/jeffrin/beautifulwork/lib/euler-three.py(12)() …
Continue reading “Project Euler Problem 3, solution internals using python debugger”
How to write an algorithm to find among natural numbers the sum of multiples of 3 and 5 below 1000 ?
/* This program has been worked on from http://www.s-anand.net/euler.html */ #include <stdio.h> sofmul() { int n, i; n = 0; for (i = 0 ; i < 1000 ; i++) { if ( !(i % 5) || !(i % 3) ) n = n + i; } printf(“Sum of the multiples of 3 and 5 …
How to write a program to multiply a number by 4 using a bitwise operator ?
/* Part of this program copied from http://www.sanfoundry.com/c-program-multiply-number-4-using-bitwise-operators/ */ #include <stdio.h> multbitwise() { long number; printf(“Enter an integer: “); scanf(“%ld”,&number); number = number << 2; printf(“Result is %ld \n”,number); } /* http://stackoverflow.com/questions/4456442/interview-multiplication-of-2-integers-using-bitwise-operators */ /* http://www.geeksforgeeks.org/multiply-two-numbers-without-using-multiply-division-bitwise-operators-and-no-loops/ */ /* http://en.wikipedia.org/wiki/Bitwise_operation */
Hacking with conversions of decimal and binary
$./app Sign detection [1] Power of two [2] Counting No. of bits set [3] Set or clear bits without branching[4] Find maximum value[5] Finding least common multiple[6] Finding the greatest commom divisor[7] Finding if a number is an Armstrong number or not[8] Finding if a given number is prime number[9] Finding the number of twin …
Continue reading “Hacking with conversions of decimal and binary”
How to write an algorithm to reverse an integer ?
/* Part of this work is copied from http://www.sanfoundry.com/c-program-to-reverse-a-given-number/ */ #include <stdio.h> revint() { long num, reverse = 0, temp, remainder; printf(“Enter the number \n”); scanf(“%ld”,&num); temp = num; while ( num > 0 ) { remainder = num % 10; reverse = reverse * 10 + remainder; num /= 10; } printf(“Given number = …
Continue reading “How to write an algorithm to reverse an integer ?”
Hacking with an algorithm to reverse an integer
$./app Sign detection [1] Power of two [2] Counting No. of bits set [3] Set or clear bits without branching[4] Find maximum value[5] Finding least common multiple[6] Finding the greatest commom divisor[7] Finding if a number is an Armstrong number or not[8] Finding if a given number is prime number[9] Finding the number of twin …
Continue reading “Hacking with an algorithm to reverse an integer”