Thursday, January 22

C code implementing a simple DFA



Hello freinds, 

Here I am posting my C implementation of DFA shown below. This DFA will accept any string containing 'a's and 'b' and last symbol should be 'a'.


#include <stdio.h>

#define TOTAL_STATES 2
#define FINAL_STATES 1
#define ALPHABET_CHARCTERS 2

#define UNKNOWN_SYMBOL_ERR 0
#define NOT_REACHED_FINAL_STATE 1
#define REACHED_FINAL_STATE 2


enum DFA_STATES{q0,q1};
enum input{a,b};
int Accepted_states[FINAL_STATES]={q1};
char alphabet[ALPHABET_CHARCTERS]={'a','b'};
int Transition_Table[TOTAL_STATES][ALPHABET_CHARCTERS];

int Current_state=q0;
void DefineDFA()
{

    Transition_Table[q0][a] = q1;
    Transition_Table[q0][b] = q0;
    Transition_Table[q1][a] = q1;
    Transition_Table[q1][b] = q0;
}

int DFA(char current_symbol)
{
int i,pos;
    for(pos=0;pos<ALPHABET_CHARCTERS; pos++)
        if(current_symbol==alphabet[pos])   
            break;//stops if any character other than a or b
    if(pos==ALPHABET_CHARCTERS)
         return UNKNOWN_SYMBOL_ERR;
    for(i=0;i<FINAL_STATES;i++)
 if((Current_state=Transition_Table[Current_state][pos])
==Accepted_states[i])
            return REACHED_FINAL_STATE;
    return NOT_REACHED_FINAL_STATE;

}


int main(void)
{

    char current_symbol;
    int result;
 
    DefineDFA();    //Fill transition table
 
    printf("Enter a string with 'a' s and 'b's:\n
                Press Enter Key to stop\n");
 
 
    while((current_symbol=getchar())!= '\n')
        if((result= DFA(current_symbol))==UNKNOWN_SYMBOL_ERR)
            break;
    switch (result) {
    case UNKNOWN_SYMBOL_ERR:printf("Unknown Symbol %c",
  current_symbol); 
 break;
    case NOT_REACHED_FINAL_STATE:printf("Not accepted"); break;
    case REACHED_FINAL_STATE:printf("Accepted");break;
    default: printf("Unknown Error");
    }

    printf("\n\n\n");

    return 0;
}


Sunday, January 11

INTERNET SECURITY : Networking Lecture Notes

TOPIC: INTERNET SECURITY



What is IPSec?
IPSecurity (IPSec) is a collection of protocols designed to provide security at the network layer.

Transport mode:  The IPSec header and trailer are added to the information  corning from the transport layer. The IP header is added later.

Tunnel mode: It takes an IP packet, including the header, applies IPSec security methods to the entire packet, and then adds a new IP header .


What are the protocols associated with IPSec?

Authentication Header (AH): provides source authentication and data integrity. The protocol uses a hash function and a symmetric key to create a message digest;


Encapsulating Security Payload (ESP) :source authentication ,data integrity and privacy


What are the reserved Addresses for private networks?
Prefix Range Total
10/8 10.0.0.0 to 10.255.255.255 2^24
172.16/12 172.16.0.0 to 172.31.255.255 2^20
192.168/16 192.168.0.0 to 192.168.255.255 2^16

What is Virtual private Network?

Virtual private network (VPN) is a technology that is  used by large organizations that use the global Internet for both intra- and inter organization communication, but require privacy in their internal communications.

VPN technology uses IPSec in the tunnel mode to provide authentication, integrity, and privacy.
All messages for internal communication will travel through Internet after encapsulated inside another packet using IPSec Tunneling.

The public network (Internet) is responsible for carrying the packet from Source side router  to destination side router. Outsiders cannot decipher the contents of the packet or the
source and destination addresses. Deciphering takes place at destination router, which finds the destination address of the packet and delivers it.

Explain Secure Socket layer (SSL)?

Secure Socket Layer (SSL) is designed to provide security and compression to data generated from the application layer.

1. SSL divides the data into blocks of 214 bytes or less.
2. Each fragment of data is compressed by using one of the lossless compression methods
3. To preserve the integrity of data, SSL uses a keyed-hash function to create a MAC.
4. To provide confidentiality, the original data is encrypted using symmetric key
5. A header is added to the encrypted payload. The payload is then passed to a reliable transport layer protocol.

Transport Layer Security (TLS) is the IETF standard version of SSL.

What is the use of Pretty Good Privacy (PGP)?
 PGP is designed to create authenticated and confidential e-mails.

What is Firewall?

A firewall is a device (usually a router) installed between the internal network of an organization and the rest of the Internet. It is designed to filter some packets.

Packet Filter: It can forward or block packets based on the IP addresses , Transport layer protocol or port addresses. It uses a filtering table to decide which packets must be discarded (not forwarded).

Proxy firewall: The server opens the packet at the application level and finds out if the request is legitimate.

Sunday, October 26

SSC CGL 2014 Questions Answer Key and Cut off

Hey friends...

Here I am posting Questions asked in SSC CGL 2014 and respective answer. Hope it will be seful for SSC Aspirants!

SSC CGL 2014

Name the Italian traveller who visited the Vijayanagar empire in 1420AD?
a)Edoardo Barbosa
b)Nicolode Conti
c) Abdur Razzag
d)Domingos Paes

Ans b

Monday, October 7

IBPS OCTOBER 2013 QUESTIONS

These are the collected Questions Asked In IBPS Exam-06-10-2013.!! hope it will be useful ..!! SHARE IT..



1. Base Rate is decided by?
2. Full Form of RKBY?- Rashtriya Krishi Bima Yojana
3. Monetary Policy is reviewed after?
4. Who is the present Shipping Minister?- G K Vasan
5. Currency of Malaysia?- Malaysian ringgit
6. PAN full form?- Permanent Account Number
7. President of France?- Francois Hollande
8. Human Rights Day is on? December 10
9. Authour of “Interpreter of Maladies”?- Jhumpa Lahari
10. Fulform of MICR?-Magnetic Ink Character Recognition
11. Headquarters of UN Population fund?- Newyork
12. Chambal river flows into?- Yamuna
13. Fund allocated to SC sub groups in budget is?
14. Capital of Greece?- Athens
15. Capital of Dadar & Nagar Haveli?- Silvassa
16. Hirakund dam is situated in?
17. FEMA enacted in which year?- 1999
18. Bank Rate is?
19. Which sports is reinstated in olympics 2020 & 2024?- Wrestling
20. Which is the tiger city?
21. What is pay now buy now?
22. Foreign exchange is managed by?
23. Five year plan is finaly aproved by?
24. Gaganjeet Bhullar is associated with which Game?- Golf
25. Abhjeet Gupta is associated with which sports?- Chess
26. Chillika lake is situated at?- Orissa
27. Cooperative societies act in which year?- 1992

Saturday, September 7

How to Create GOD MODE FOLDER in Windows 7


Hello folks,

This time I'm gonna tell an interesting yet quite useful trick to you. This will help you to make a GOD MODE FOLDER in Windows 7 in just two steps..!!



Wait, What is this GOD MODE FOLDER??


Okay, Simply speaking  it's a folder containing all the shortcuts to just about every settings change and administrative function in Windows 7...!! 

Good.. But Why I need??

Just think ~ All settings in one folder..!! You don't need to swing from one category to another to edit your preference. Usually you have to scan a lot in all categories unless you know exactly where you can edit..

And, it also provides how much we can explore in settings of Windows..!!it's a pretty long list of things to remember - so having a nice reference like this could actually be useful from time to time.

Great... How to create this GOD MODE FOLDER??


Yeah.. With just TWO steps.!!!
  • Create a new folder anywhere
  • Rename the folder and paste in the following text:
    GodMode.{ED7BA470-8E54-465E-825C-99712043E01C}
    Cool na?  Hope this trick will be useful for you..!!  :)


Thursday, August 29

Trick to Find Cube Root of a number without Calculator








Today I 'm gonna share a simple  trick to find the Cube Root of any number (perfect Cubes only) without the need of any calculator..!! A sample C program is also providing to  prove this trick will work correctly for all perfect cubes.!!
Here We Go..!!  :)








Trick Used:

We will follow these steps to find the cube root of a number:

1. Ignore the last 3 digits of the number. Let remaining number be “Part1”.
2. From the above table check which number’s cube is less than or equal to ‘Part1’. It will be left part of our answer. Let it be “L”.
3. Let Right part of our answer be “R”. It will be determined from the above table. For Ex. If last digit of question is 7, then last digit of our answer will be 3
4. Our answer will be L|R.


Example 1
Suppose we want to find the cube root of 21952.
Step 1: Ignore last three digits of 21952. Remaining number left is ’21′.
Step 2: From the above table cube of ’2′ is less than ’21′. Therefore left part (L) of our answer will be ’2′.
Step 3: Since last digit of ‘21952‘ is ‘2‘. Therefore right part (R) of our answer will be ’8′. (Because Last digit of ‘cube of 8′ is 2. see table above.)
Step 4: Our Answer will be L|R. Therefore Answer will be 2|8 = 28.

PROOF

This C program verifies  this trick that it will work correctly for all perfect cubes.!!

#include<stdio.h>

int main()

{
 int cube[]= {0,1,8,27,64,125, 216,343 ,512 ,729 };
 int last_digit[]={0,1,8,7,4,5,6,3,2,9};
 int i=0,j=0, num, part1,part2, ans1, ans2,flag;


flag =1;
for (i=0 ;i<44;i++)
{
num =i*i*i;                  // eg : 21952
part1 =  num/1000;           // 21
for (j=0;j<10;j++)

if (cube[j]>part1)           // 27>21
 break;                      //j=3
  ans1 =j-1;                 // ans1 =2

part2 = num%10;              //2
for (j=0;j<10;j++)
if(part2 == last_digit[j]) break;

ans2 = j;                    //8

ans1= ans1*10 +ans2;         //28

if (i!=ans1)  flag = 0;

}    
 if (flag) printf ("VERIFIED");
else printf ("ERROR OCCURED");

      return 1;
      }




Hope this post was useful for you.!!
Your feedback and suggestion are always welcome..!! Keep in touch.
hugs :)



Friday, July 26

Prasar Bharti Engineering Assistant Exam 2013 Complete Solution




Hello folks,

Here I'm providing the complete questions and solutions for Prasar Bharti Engineering Assistant Exam 2013 Complete Questions and answers held on 21 July 2013.

1.  Identify the leader of Satya Shodhak Samaj:

A. Dayanand Saraswathi

B. Jyotiba Phule

C. Gopal Krishna Gokhale

D. Dadoba Pandurang

2. The highway road  network in Germany is called:

A. Autoroute

B. Autobahn

C. Autostrade

D. Autoway

3. When lactate is used to synthesize glucose/glycogen, the process is called:

A. Gluconeogenesis

B. Glucogenesis

C. Glycogenesis

D. Glyconeogenesis

4. If Gross domestic Product is greater than Gross National Product, it means

A. Indirect taxes are greater than subsidies.

B. subsidies are greater than Indirect taxes.

C. Imports are greater than exports.

D. exports are greater than imports.

5. Marginal cost of nth unit is equal to

A. TCn - TC n-1

B. TCn - TC n+1

C. TCn + TC n-1

D. TCn + TC n+1

6. One of the following statements is wrong:

A. Competition is free markets promotes efficiency in the working of capitalistic economy

B. The main objective of capitalism is to bring about a socialistic pattern of society.

C. Profit motive is the heart of all the institutions of capitalism

D. private ownership of property is indospensible for proper functioning of capitalism

7.The law of demand expresses

A. an opposite relationship between the demand of a commodity and it's supply.

B. a direct supply between income of a  consumer and his demand

C. a positive relationship between the income of a  consumer and his demand

D. an inverse relationship between the quantity demanded and the price of a commodity.

8. A netadditiontoalready existing stock of capital means:

A. positive net Saving

B. improved technology

C. increased production

D. positive net investment

9.  The system of delegated legislation has  enhanced the power of the

A. Bureaucracy

B. Legislature

C. Legislature Committees

D.Council of ministers

10. Martin Luther was related to

A. reformation

B. geographical discovery

C. restoration

D. renaissance

11. The idea of popular Sovereignty was advocated by:

A. Locke

B. Rousseau

C. Austin

D. Hobbes

12. Without prior intimation, any member can raise a question  on any issue in parliament during

A. Zero hour

B.recess Time

C. Closure motion

D. Question Hour

13. Which committee recommended Fundamental duties for the citizens?

A. Swaran singh

B. raj narain

C. Balwant rai

D. Patel

14. The idea of" reverse discrimination" implies

A. Discrimination in decreasing order.

B. equating rich and poor in electoral arena

C.bestowing favored treatment to the hitherto deprived sections

D. establishing institutional checks against arbitrary distinction

15. Chola's local self government had assemblies of _____ types.

A. 4

B. 5

C. 6

D. 3

16.ITCZ refers to __________ Zone

A. inter Trade Center

B. Inter Tropical convergence

C. Inter Transitional Center

D.Inter Transitional convergence

17. Stream Frequency is the

A. Area required to sustain one unit length  of  the channel

B. Number of channels per unit area

C. Channel area per stream

D. Channel length per unit area

18.  Which of the following seas is without  coastline?

A. Sargaso sea

B. Sea of Okhotsk

C. Tasmania sea

D. White sea

19. Identify the leader of Satya Shodhak Samaj

A. Dayanand Saraswathi

B. Jyotiba Phule

C. Gopal Krishna Gokhale

D. Dadoba Pandurang

For complete question set Click here