Showing posts with label Coding puzzles. Show all posts
Showing posts with label Coding puzzles. Show all posts

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; ...

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...

Tuesday, June 12

ECIL Graduate Engineer Trainee (GET) recruitment 2012 Computer (CSE) Questions and Answers

Hi Friends, Here I'm posting the questions asked in ECIL (GET) exam, held on 2012 August 10 , for Computer science, and its detailed solution. All the questions and answers are collected from memory with the help of  friends..!!! Hope this will be useful for the preparation for various PSU exams. Feel free to comment your feedback and doubts ..!! Here we Go..!! :) ECIL (GET) Computer science Stream Total No Questions: 50 Time Duration: 2 Hrs (1 )"Bit Stuffing" is used for? a. Code transparency b. Synchronization between sender and receiver c. Data Compression d. Data Encryption  Ans: (B) Bit stuffing means...