Monday 25 February 2019

Running Bash Script

1. $PATH  ensure the path is correct
2. Consider storing script in $User/bin which is /usr/local/bin
3. Run the script using ./srcipt-name . refers to current directory
4. in order to run the script, the script should have execute permission, to give permission
          chmod   +x myscript
5. bash myscript to run script.
6. executing script ./script-name i.e. executing without ./ can return un-expected results. to validate execute the command using which command.


Exit And Exit Status

The exit command terminates the script & returns an value, this value is available with the scripts parent process. 

A successful exit returns 0, while an un-successful exit returns value greater than 0


Linux shell shebang

Starting an script with #!  is called shebang or bang line. 
This is the absolute path to Bash interpreter. 
Almost all bash scripts often begin with the #!bin/bash. 
This ensures that Bash will be used to interpret the script. 

If you do not specify an interpreter line, the default is usually the /bin/sh. But, it is recommended that you set #!/bin/bash line    

Saturday 23 February 2019

TWO's COMPLEMENT

This section is divided into
1. What is the significant of LSB
2. What is the Significant of MSB
3. What is Complement in computer science
4. What is One's Complement
5. What is Two's complement

Least significant bit - 
The least significant bit in the Binary number is the UNIT value,  Least significant bit helps to determine if the number is the ODD or the EVEN Number.

How to determine if the number is ODD or EVEN ?
The simplest way is to use modulo(%) operator 

pseudo code - 
if  no % 2 == 0 then
     print "even number"
else 
     print "odd number"

using binary operation ?
example number 2 in binary format is represented as 10 and number 3 in binary format is represented as 11

Bit-wise  And (&) operator can be used to determine if the number is the ODD no or EVEN no.
Truth Table
1 & 1 = 1
1 & 0 = 0
0 & 1 = 0 

hence 

Binary format of 2 -->    1  0
Binary format of 1 -->    0  1
                                     &
--------------------------------------
                                            0

Hence the no is even no

     
Binary format of 3 -->    1  1
Binary format of 1 -->    0  1
                                     &
--------------------------------------
                                            1

Hence the no is ODD No


Most significant bit - 
Most significant bit is the (or higher order bit) is the bit position in binary number having greatest value.

The MSB can also correspond to the sign bit of a signed binary number in one's or two's complement notation, "1" meaning negative and "0" meaning positive


What is Complement in Computer Science ?

the method of complements is a technique used to subtract one number from another using only addition of positive numbers.

One's complement

One's complement is inverting bit i.e changing '0' to '1' and vice versa .

Two's Complement

do One's complement  and add one. 

example 
100 - 22 = ?








Saturday 9 February 2019

Angular Interview Questions

1.What is the difference between Angular Module & ES 2015 Module ?
2. 

Sunday 3 February 2019

Inverted Index

What is Indexing? 
Making information presentable .

What is the purpose of Indexing?
To retrieve information Faster. 

What is Inverted Index ? 
An Inverted index is an index data structure, that stores the mapping from content(like words & numbers) to its location in database file or documents or set of documents.

Variants of Inverted Indexing?
1. record-level inverted indexing - maintains a list of references to documents for each word.
2. word-level inverted indexing - maintains the position of each word in document.

What is the purpose of inverted indexing?
For faster searching, is used by search engine.