| Posted: The answer is that you need to store all possible configurations of the board and the move that is associated with that. Then it boils down to just accessing the right element and getting the corresponding move for it. Do some analysis and do some more optimization in storage since otherwise it becomes infeasible to [...] |
| Give a very good method to count the number of ones in a “n” (e.g. 32) bit number. Posted: Given below are simple solutions, find a solution that does it in log (n) steps. Iterative function iterativecount (unsigned int n) begin int count=0; while (n) begin count += n & 0×1 ; n >>= 1; end return count; end Sparse Count function sparsecount (unsigned int n) begin int count=0; while (n) begin count++; n [...] |
| Posted: I gave the obvious solution of taking % 10 and / 10, which gives us the decimal value in reverse order. This requires an array since we need to print it out in the correct order. The interviewer was not too pleased and asked me to give a solution which did not need the array |
| Posted: There are 45 different 3-digit numbers. The last digit can not be 0. If the last digit is 1, the only possible number is 101. (Note that 011 is not a 3-digit number) If the last digit is 2, the possible numbers are 202 and 112. If the last digit is 3, the possible numbers are 303, [...] |
| Posted: Assume that you start counting on 1 January 2001. 9 Years, 187 Days, 5 Hours, 20 minutes As you can count 200 per minute, to count 1 billion you require = 1,000,000,000/200 minutes = 5,000,000 minutes gy majors, & 62% are business majors. If there are 200 students, how many of them are majoring in both [...] |
| Posted: Divide the number of juniors (187) by the total number of student (981), & then multiply the number by 100 to convertto a percentage. Hence the answer is (187/981)*100 = 19% |
| Posted: They played total of 9 games. Jack won 3 games and Jill won6 games. If Jack has won three games and Jill has won $3, she lost adollar for each loss, therefore she has won 6 and lost 3 to make $3 and he won the other 3 that she lost |
| Posted: 24.(logical xpln) assume 100 rs & 30 apples.i.e 3.33/ apple. for 20 % profit i.e 20 rs, each apple 2 b sold at 4 rs. but he has to sell it in rs 100 therefore no of apples shud b reduced. to earn 20 rs =3.33*(6) approx.therefore 6 less apples thus 24 apples |
| Posted: Rate should be Rs 150 per meter (not sqm). (Rs 150 / m) * circumference = (Rs 150 / m) * pi * diameter = (Rs 150 / m) * (22/7) * 70 m = Rs 150 * 22 * 10 = Rs 33000 |
|
Posted: Could you please explain me how you got 6 as your answer. I could do it in a minimum of 11 races. There has to be atleast 5 races to select 15 horses. The 15 horses then compete among themselves and best 9 horses are chosen. The 9 horses then run in groups of 5 [...] |
| Find out the smallest four digit number which is divisible from 1 to 10? Posted: 1050. I multiplied all the prime numbers from 1 - 10 and then found its(210) smallest 4 digit multiple which is 1050 |
| I can take a bca student instead of you then why should i hire you Posted: You can get a uneducated person for 1/4 to 1/10 of salary why don’t you hire him. Answer is quality, understanding, future value addition etc. |
| Posted: Here the realative speed is 60+60=120kms/hr…. The distance between them was 18kms when the shuttle begins to fly in between them….. To cover 18 kms with a relative velocity of 120 kms/hr the time would be 18/120,ie,=3/20 so shuttle can fly ((3/20)*80) kms before the two trains crashes,so the answer is 12 kms… |
| Posted: Break the gold bar at 3 position then u will get 2(1,2),1(3),4(4,5,6,7) combination gold bar and break at middle in 4 segment (4,5,6,7)in middle so that there will be 2 segment combination(4,5)and (6,7) at 1st day the owner gives 1 the 2nd day he gives 2 and takes 1 and 3rd day he gives 1,4th [...] |
| Posted: Take 3 and 3 balls in each of balance and keep other 2 aside.If there is any defective ball in 3 balls either there will beunbalance.if so take those 3 balls aside which has no defective ball. |
| Posted: Join the centers of the original and the removed rectangle. It works for cuboids too! BTW, I have been getting many questions asking why a horizontal slice across the middle will not do. Please note the “any size or orientation” in the question! Don’t get boxed in by the way you cut your birthday cake [...] |
| Can you tell who is the Doctor and the Engineer? Posted: Mr. Bajaj’s wife and mother are not blood relatives. So from 3, if the Engineer is a female, the Doctor is a male. But from 1, if the Doctor is a male, then the Engineer is a male. Thus, there is a contradiction, if the Engineer is a female. Hence, either Mr. Bajaj or his [...] |
| Posted: The last person covered 120.71 meters. It is given that the platoon and the last person moved with uniform speed. Also, they both moved for the identical amount of time. Hence, the ratio of the distance they covered - while person moving forward and backword - are equal. Let’s assume that when the last person reached the [...] |
| Posted: Assume that initial there were 3*X bullets. So they got X bullets each after division. All of them shot 4 bullets. So now they have (X - 4) bullets each. But it is given that,after they shot 4 bullets each, total number of bullets remaining is equal to the bullets each had after division i.e. X Therefore, the equation [...] |
| You have to draw 3 concentric circles with a line passing thru their centerwithout lifting hand. Posted: Start the line complete one circle move inside circles along the line and then draw second circle. Like wise rest. |
Blog Archive
-
▼
2008
(46)
-
▼
November
(28)
- RARE QUESTIONS
- TECHNICAL QUESTIONS
- TECHNICAL QUESTIONS
- LATEST TECHNICAL QUESTIONS
- TACKLING CAMPUS INTERVIEWS
- TECHNICAL QUESTIONS
- TECHNICAL QUESTIONS
- IMPROVE YOUR SELF CONFIDENCE
- KEYS TO SUCCESSFUL JOB INTERVIEWING
- FACING AN INTERVIEW IS AN ART
- MAKE A BIG IMPRESSION AT YOUR INTERVIEW !!
- INTERVIEWS:WHAT DO THEY LOOK FOR?
- HOW TO FACE TOUGH INTERVIEW QUESTIONS
- INTERVIEW ETIQUETTES
- TIPS FOR INTERVIEW
- BASICS OF AN INTERVIEW
- 2000 INTERVIEW QUESTIONS:SERIES 1
- 2000 INTERVIEW QUESTIONS:SERIES 2
- GD TOPICS:SERIES 1
- 10 SIMPLE WAYS TO CRACK GD
- WHAT IS GROUP DISCUSSION?
- GD TOPICS:SERIES 2
- GD TOPICS:SERIES 3
- GROUP DISCUSSION TIPS FOR FRESHERS
- SOFT SKILLS
- TECHNICAL QUESTIONS
- TECHNICAL QUESTIONS
- LATEST INTERVIEW QUESTIONS
-
▼
November
(28)
Tuesday, November 18, 2008
RARE QUESTIONS
Monday, November 17, 2008
TECHNICAL QUESTIONS
How can MYSQL functions be available with PHP? Posted: MYSQL is not available as a default feature it must be created by the user. You can use –with-mysql=DIR function to make available SQL on your system. Compiling PHP functions with MYSQL will increase the support and functioning of the language. MYSQL should be installed where there are extensions of PHP. |
| Explain about the connective abilities of the PHP? Posted: A huge advantage for PHP is its connective ability. It uses huge number of extensions to interface with huge pool of libraries such as XML, graphics and encryption. Programmers can create their own extensions and compiling them. They can load their own programs by using the dynamic loading mechanism. |
| Explain about the advantages of using PHP? Posted: There are many advantages of PHP they are 1) Easy and fast creation of dynamic web pages and a developer can also embed these dynamic functions into HTML. 2) A huge community resource which has a ton of information before you. 3) Connectivity ability lets you to connect to different interfaces and predefined libraries. 4) Execution is very fast [...] |
| How to change the principal password? Posted: Principal password can be changed by using kadm5_chpass_principal command. If you also want to specify the new password for effecting a change to the principal password it should be as Bool kadm5_chpass_principal (resource $handle, string $principal, string password). This changes the password to password. |
| Explain about the casts allowed in PHP? Posted: Type casting acts and functions similarly as it performs in C. The casts allowed are Integer, Boolean, float and double, string, binary, array and object. Casting and support was added in PHP 5.2.1. A variable can be enclosed in double quotes instead of casting it to a string. |
| Posted: PHP uses Type juggling similar to the way Perl uses. Variable is defined in the context in which it is used. It doesn’t require any explicit definition for a function to perform its duties. For example if a string value is assigned to a variable it is defined as string. |
| Explain about Booleans in PHP? Posted: A Boolean type states a truth value whether it is true or false. These statements are case insensitive. An operator returns a Boolean value and this value is passed onto the control structure which executes the statement. If an argument is required it is automatically converted. |
| Posted: Looping statements are used in PHP to execute the code for a developer defined number of times. PHP has these following looping statements they are while, do while, for and for each. Foreach is used to loop a block of code in each element in an array. |
| Explain about mixed and callback functions? Posted: Mixed function indicates that the function may contain multiple types but it doesn’t form a necessary condition. Functions like call_user_func() or usort() accept user defined functions as parameter. These functions are not only simple but also object methods which includes static methods. |
| Posted: Null represents a variable with no value inside. There doesn’t exist any value for type Null. Null is defined to be null if and only if it is assigned a constant null, there is no value set, it is set to be unset(). This is the case insensitive keyword. There are also two functions they [...] |
| Posted: Resource holds reference to an external resource and it is a special variable. These are created and used by specially defined functions. Resource holds defined and special handlers for opening files. Converting to a resource makes no sense at all. |
| Explain about converting an object? Posted: When an object is converted into an object the stance of the object is not modified. A new instance of the class is created if a value of different type if converted into an object. Incase the value is null at the time of conversion the new instance will be empty. |
| Explain about array uintersect()? Posted: This function is very useful in PHP. This function compares array values in a user defined function and it returns the array. If assoc() is added to the function it compares array keys. This function can also be defined as array uintersect uassoc(). |
| What are the different opening and closing tags available in PHP? Posted: There are four different types of tags available in PHP they are * PHP short tags * ASP style tags. Generally the first two tags are widely used because they are portable. |
| Posted: Parsing is an important concept if you want to run your code appropriately and timely. PHP parses all the code present between the opening and closing tags, it ignores everything present out of the closing and opening tags. This tags allow PHP to be embedded between many documents. |
| Explain about the installation of PHP on UNIX systems? Posted: PHP can be installed on UNIX in many different ways there are pre defined packages available which can ease the process. Initially it can be controlled by the command line options. Help can be obtained from./configure help command. After installing PHP modules or executables can be configures and make command should help you in the [...] |
| Posted: Personal home page language is used to create dynamic and interactive websites which are very efficient in delivering client needs from the server side. This language is widely used. It is used on various operating systems with Apache modules. This can be directly embedded into HTML code. |
| Posted: portal registry is a tree-like structure in which content references are organized, classified, and registered. It is stored in a set of tables within a PeopleSoft database made specifically for hosting portal registries. Portal registries contain folders and content references. Folders are similar to nodes on a tree and can be nested to create a [...] |
| Where do you set Peoplecode trace? Posted: Peoplcode trace can mean setting peoplecode trace for record peoplecode or for app engine(on execute). For getting the trace for peoplecode(record level), need to go to options and select various levels of trace by checking what level u wat( Stack, every instruction, list the program, etc) and select the destinationfile to which the generated trace needs [...] |
| what is PSCAMA(Peoplesoft Application messaging at… Posted: PSCAMA contains fields common to all messages. The tag repeats for each row in each level of the section of the message. The sender can set PSCAMA fields to provide basic information about the message. For example, to indicate the message language or the type of transaction a row represents. When receiving a message, your PeopleCode [...] |
TECHNICAL QUESTIONS
What Are the Special Characters You Need to Escape in Single-Quoted Stings? Posted: There are two special characters you need to escape in a single-quote string: the single quote (’) and the back slash (\). Here is a PHP script example of single-quoted strings: This script will print: Hello world!It’s Friday!\ represents an operator. |
| Posted: A standard alone PHP script can be executed directly with the PHP Command Line Interface (CLI). Write the following script in a file called hello.php: This script can be executed by CLI interface like this: \php\php hello.php You should see the “Hello world!” message printed on your screen. |
| Where Are PHP Configuration Settings Stored? Posted: PHP stores configuration settings in a file called php.ini in PHP home directory. You can open it with any text editor to your settings. |
| How To Download and Install PHP for Windows? Posted: The best way to download and install PHP on Windows systems is to: ► Go to http://www.php.net, which is the official Web site for PHP. ► Download PHP binary version for Windows in ZIP format. ► Unzip the downloaded file into a directory. You are done. No need to run any install program. |
| How To Check Your PHP Installation? Posted: PHP provides two execution interfaces: Command Line Interface (CLI) and Common Gateway Interface (CGI). If PHP is installed in the \php directory on your system, you can try this to check your installation: * Run “\php\php -v” command to check the Command Line Interface (CLI). * Run “\php\php-cgi -v” command to check the Common Gateway Interface (CGI). If [...] |
| How To Download and Install PHP on Windows? Posted: PHP is one of the most popular languages to develop dynamic Web pages. It supports all major database servers, including: MySQL, MS SQL Server, Oracle, mSQL, Sybase, etc. If you are developing a Web application that uses PHP and needs to access MS SQL Server, you should go download and install PHP to your local machine [...] |
| Do you have any questions for me? Posted: Always have some questions prepared. Questions prepared where you will be an asset to the organization are good. How soon will I be able to be productive? and What type of projects will I be able to assist on? are examples |
| Tell me about the most fun you have had on the job. Posted: Talk about having fun by accomplishing something for the organization. |
| What has been your biggest professional disappointment? Posted: Be sure that you refer to something that was beyond your control. Show acceptance and no negative feelings. |
| Posted: Emphasize benefits to the organization. Things like, determination to get the job done and work hard but enjoy your work are good. |
| What position do you prefer on a team working on a project? Posted: Be honest. If you are comfortable in different roles, point that out. |
| Tell me about a time when you helped resolve a dispute between others. Posted: Pick a specific incident. Concentrate on your problem solving technique and not the dispute you settled. |
| What qualities do you look for in a boss? Posted: Be generic and positive. Safe qualities are knowledgeable, a sense of humor, fair, loyal to subordinates and holder of high standards. All bosses think they have these traits. |
| How do you propose to compensate for your lack of experience? Posted: First, if you have experience that the interviewer does not know about, bring that up: Then, point out (if true) that you are a hard working quick learner. |
| Do you think you are overqualified for this position? Posted: Regardless of your qualifications, state that you are very well qualified for the position. |
| If you were hiring a person for this job, what would you look for? Posted: Be careful to mention traits that are needed and that you have. |
| Posted: Trick question. If you know about blind spots, they are no longer blind spots. Do not reveal any personal areas of concern here. Let them do their own discovery on your bad points. Do not hand it to them. |
| What have you learned from mistakes on the job? Posted: Here you have to come up with something or you strain credibility. Make it small, well intentioned mistake with a positive lesson learned. An example would be working too far ahead of colleagues on a project and thus throwing coordination off. |
| Describe your management style. Posted: Try to avoid labels. Some of the more common labels, like progressive, salesman or consensus, can have several meanings or descriptions depending on which management expert you listen to. The situational style is safe, because it says you will manage according to the situation, instead of one size fits all. |
| Are you willing to put the interests of the organization ahead of your own? Posted: This is a straight loyalty and dedication question. Do not worry about the deep ethical and philosophical implications. Just say yes. |
Friday, November 14, 2008
LATEST TECHNICAL QUESTIONS
Write about the following instruction : Posted: Offset of the first instruction of procedure is in two memory addresses in DS. It replaces the contents of IP with contents of word memory locations in DS pointed to by BX. |
| Write about EVEN directive in 8086 ALP. Posted: It forces the address of the next byte to be even. 8086 words can be accessed in less time if they begin at even address. |
| Posted: (i)SP =SP-2 , stack ß Push flag reg. Contents, IF =0 , TF =0 (ii) SP=SP-2, Stackß CS Reg. Contents, Address of Interrupt pointer = Interrupt type * 4 , CS Register Contents ß Second word of Interrupt pointer (iii) SP=SP-2, Stackß IP, IPß First word of Interrupt pointer |
| Define LAHF and SAHF instructions in 8086. Posted: LAHF : Load the 8085 equivalent flags into the AH register. SAHF: Store the AH register into the low order byte of the flag register. |
| What is the use of TEST instruction in 8086? Posted: Test instruction is the same as the AND instruction except that ite does not put the result anywhere. Like the CMP instruction , it is used only to set the flags. |
| Posted: Emulator is a mixture of hardware and software .It is used to test and debug the hardware and software of an external system such as the prototype of a microprocessor based instrument. |
| Define EXTRN directive in in 8086 assembly language? Posted: The EXTRN directive is used to inform the assembler that the names or labels following the directive are in some other assembly module. |
| Write the use of Assume directive in 8086 assembly language using one example? Posted: Assume CS: code_here, DS:data_here It tells the assembler that the logical segment code_here contains the instruction statements for the program and should be treated as a code segment. It also tells the assembler that it should treat the logical segment data_here as the data segment for this program. |
| Define EQU directive in 8086 assembly language? Posted: It is used to assign a name to constants used in the programs. Consider the statement ‘corr EQU 07H’ , this would tell the assembler to insert the value 07H everytime that it finds the name corr in the program statement. |
| How the execution time of an instruction is calculated? Posted: Execution time of an instruction can be determined by multiplying the number of clock pulses needed to execute the instruction by the clock period. |
| Write the use of Z bit in opcode? Posted: It is used by REP instruction. Z bit helps to control the loop. It will be repeated the number of items indicated by the CX register or until Z bit dose not match the Zero flag whichever occurs first. |
| What is the use of V bit in opcode ? Posted: It is used by shift and rotate instructions to determine the number of shifts. V bit is set to 0 if the shift count is to be 1. V bit is set to 1 if the CL register contains the shift count. |
| What is the use of D bit in opcode? Posted: D bit: It is used in double operand instruction. It is used to indicate whether the register specified by REG is the source operand (D=0) or the destination operand (D=1). |
| Write about the following instruction : LES CX, [3483H] Posted: Copy the contents of memory at the displacement of 3483H in DS to CL, contents of 3484H in DS to CH, and copy the contents of memory at displacement of 3485H and 3486H in DS to ES Register. |
| Write the difference between CBW and CWD instruction in 8086. Posted: CBW : Convert a byte to a word, sign extend AL Register into a AH Register. CWD : Convert a word to a double word ,sign extend the AX Register into the DX Register |
| Define Segment Override Prefix. Posted: Segment Override Prefix : To permit exceptions to the Segment Register usage, a special one byte instruction called a segment override prefix is available . It is of the form : |
| Posted: Unpacked BCD Format : In Unpacked BCD, there is only one digit per byte and because of this,unpacked multiplication and division can be done. Binary operations act on signle bytes and the results are adjusted. For Division , the adjustment is done before the binary division. |
| What is AAS instruction in 8086 ? Posted: Adjust Result of ASCII Subtraction This instruction adjust the binary result of SUB or SBB instruction. |
| What is the use of Directives in 8086 ? Posted: Directives in 8086 give directions to the assembler during the assembly process but are not translated into machine instruction. |
| Posted: Programmed I/O : It consists of continually examining the status of an Interface and performing an I/O operation with the Interface when its status indicates that it has data to be input or its data- out buffer register is ready to receive data from the CPU. . |
Thursday, November 13, 2008
TACKLING CAMPUS INTERVIEWS
As a large chunk of students are already placed in various leading IT and allied industries, its almost dusk over the placements for the 2008 passouts, its dawn for the 2009 (passouts) placement season. Let me give you a brief write up of how to tackle campus interviews from the little experience I had during this fruitful season.
Let us start with the procedure of how various companies have their recruitment procedure -
The first step is the Aptitude Test – This includes all kinds of elementary maths and simple logical reasoning. The next phase which is generally augmented with the test is the Technical Test. Software companies (and even purely Electronics based companies like L & T) have a C test. Its mostly of the kind “what would be the output of..” or “ find the error”. Wipro Technologies had a paper which contained a few general things also (questions generally found in technical quiz e.g expand MIME). There is a considerable amount of screening in the first phase.
The short listed candidates are let through either Group Discussion followed by Interview sessions or directly the Interviews. ( Most companies have GDs - exceptions include Wipro Technologies, CTS, Elxsi etc.) The Interview is again of two kinds. First, the Technical Interview wherein our technical abilty is tested and in the second stage, known as the Personal Interview or more generally the HR interview, is mostly a stress interview. Things in your resume are validated in this round and the amount of confidence and communication ability is taken into concern. Once you clear this – “You are Placed” .
Now that the procedure of placement is clear, Lets optimise our preperation so that we really donot need to struggle through the various phases.
Basic Ground Work to be done includes – having a general idea about various companies & the kind of work they do. I wouldn’t always suggest that we should choose our First Job, all that it matters is a relevant job for our BTech. But in a situation that you are looking at your second (alternate) job, I would say, be very choosy.
Getting equipped for Aptitude and Technical Rounds - If I begin listing the names of books required for the aptitude, that would be very long. Generally its basic maths (maths upto X class level) that is tested and being an engineering student, it shouldnt be a problem for us. But speed is all that matters. Most companies have a high cut off for their test and also take into regard the negative marks. So be careful. The only way of improving speed is by practice. I had prepared my aptitude from IMS books for CAT, that was much more than enough. The other favorite books include Shakuntala Devi, RS Agarwal etc. With improved aptitude , the next look out matter is English. It is an uphill task for normal guys to crack this section, but yet again paractice will help. GRE English by Barrons is the most preferred book.
There is also a certain style that each company follows, they do not easily drift from that. Solving previous papers of the compnies (availble in plenty in net – chetanajobs. com, freshersworld. com etc ) is a very good thing to do. Even in the english section, it is not easy to memorize the 5000 odd words in Barrons, this is where old papers help. (This is to be done at the begining of the placement season, doing it way ahead might not be useful).
The next section is C, Yashwant Kanitkar’s Let us C is a good book to learn from the ground level. It is to be understood that the C we learn in our academics is absolutely not sufficient. Structures, Pointers and File operations are important. For the “debugging and output” section, Exploring C by Yashwant Kanitkar is the best book. Most companies have their C part from this book.
Beginning with the preperation for Interviews - We basically need to tell them which subjects are we strong in. Please give only relevant subjects. For a computer student OS, Data Structures, DBMS and Software Engineering are the most expected ones. When you say it is your favorite subject, they expect us to be proficient enough in these subjects. So study these papers conceptually with a “practical orientation – real life situations “ in mind. Although we dont mention these subjects, questions will be asked from them. Mini Project is the next important thing in this round. We are expected to make them understand what our project is in 4-5 sentences. The next obvious question is “what is your role in this project” or “explain your project according to s/w life cycle”. So be prepared. A good project certainly leaves a good impression in the interviers mind- so choose good projects ( with good application and industrial flavour ).
Finally we have the HR interview - Stress questions are asked and we are made to commit mistakes. All it matters is how confident and cool we are. General questions include “describe yourself” , “ hobbies / interests” , “strenghts / weaknesses” , ‘ what do you know about our company / why do you want to join us”, “short term / long term plans”, “do you have any questions to ask us”. Prepare good answers for all these questions and make sure that your answers are brief enough and well structured. Keep in mind that they are ultimately testing your communication skills and attitude through these questions.
Academics – 75 % + with no back logs will qualfy you for almost every test everywhere. Remember good academics is an added advantage.
Resume- your resume reflects your personality. So try being unique while preparin your resume. Also please mention thing which are very much true. If you mention that you like reading, most probably the immediate questions are – which is the last book you have read/ what is the story/ who is the hero in that, there is every chance that the person sitting over there has also read that book – so no bluffing.
Dress Code – Be neatly dressed preferably in uniform. Full hands shirt gives a better look. It is good if we have a new pair of uniform for these interview(s) to be attended. Be Clean and Tidy- no long nails ,hair well combed and a fresh look on your face.
Make it a point to browse the company web site and learn a few things about it. It can be used to answer a few questions in the HR round also it implicates that we are serious about that company and have put some amount of ground work for this interview.
Keep your mind cool and stay calm. Do not hurry with your answers and decisions. Keep a positive attitude. Being different or eccentric will never help you. Think as both a team leader and a team player. All that it matters is how we present ourselves – so make sure that you are at your best. Take suggestions from seniors and others in the industry, it helps a lot. Having GDs, simulating Interviews, taking mock tests etc are the other improvisation techniques to be adopted.
There is a very important factor that also plays a considerable role – FATE although its next only to hardwork and determination.
ALL THE BEST !!
GOD BLESS YOU.
Tuesday, November 11, 2008
TECHNICAL QUESTIONS
Write a C function to print the link list in reverse order Posted: A: void Display_List_Reverse(struct node* current) { if (current==NULL) return ; Display_List_Reverse(current->next); printf(” |
| Implement a breadth first traversal of a binary tree Posted: The breadth first traversal of a binary tree can be accomplished by making use of a queue to store the elements from the tree that need to be printed next. Assuming a node in the binary tree is defined as follows: struct Node { int value; Node* left; Node* right; }; Here is an [...] |
| Posted: A: The obvious brute force solution would involve checking each item in the array to see if matches the desired value. This does not take advantage of the fact that the rows and columns in the array are sorted. The trick is to find a way to eliminate rows and columns from the array and [...] |
| What is the effective way of Device Independent Bitmap files management? Posted: A: Memory-mapped file is the best choice for device-independent bitmaps. MMF allows to map the file to RAM/SWAP addresses and to let Windows handle all load/unload operations for the file. |
| Set the highest significant bit of an unsigned integer to zero. Posted: (from Denis Zabavchik) Set the highest significant bit of an unsigned integer to zero #define zero_most_significant(h) (h&=(h>>1)|(h>>2), h|=(h>>2), h|=(h>>4), h|=(h>>8), h|=(h>>16)) |
| How do we test most simply if an unsigned integer is a power of two? Posted: A: #define power_of_two(x) ((x)&&(~(x&(x-1)))) |
| Compute the discrete log of an unsigned integer. Posted: A: #define discrete_log(h) (h=(h>>1)|(h>>2), h|=(h>>2), h|=(h>>4), h|=(h>>8), h|=(h>>16), h=(0xaaaaaaaa&h)>>1+(0×55555555&h), h=(0xcccccccc&h)>>2+(0×33333333&h), h=(0xf0f0f0f0&h)>>4+(0×0f0f0f0f&h), h=(0xff00ff00&h)>>8+(0×00ff00ff&h), h=(h>>16)+(0×0000ffff&h)) If I understand it right, log2(2) =1, log2(3)=1, log2(4)=2….. But this macro does not work out log2(0) which does not exist! How do you think it should be handled? |
| Compute the number of ones in an unsigned integer. Posted: A: #define count_ones(x) (x=(0xaaaaaaaa&x)>>1+(0×55555555&x), x=(0xcccccccc&x)>>2+(0×33333333&x), x=(0xf0f0f0f0&x)>>4+(0×0f0f0f0f&x), x=(0xff00ff00&x)>>8+(0×00ff00ff&x), x=x>>16+(0×0000ffff&x)) |
| Reverse the bits of an unsigned integer. Posted: A: #define reverse(x) (x=x>>16|(0×0000ffff&x)8|(0×00ff00ff&x)4|(0×0f0f0f0f&x)2|(0×33333333&x)1|(0×55555555&x) |
| Reverse a singly linked list recursively. The function prototype is node * reverse (node *) ; Posted: node * reverse (node * n) { node * m ; if (! (n && n -> next)) return n ; m = reverse (n -> next) ; n -> next -> next = n ; n -> next = NULL ; return m ; } |
| Posted: Start reversing the list. Do this again, printing the contents. tags: microsoft sw programming |
| Posted: A: a) have an array of length 26. put x in array element corr to a put y in array element corr to b put z in array element corr to c put d in array element corr to d put e in array element corr to e and so on. the code while (!eof) [...] |
| Given a linked list with the following property node2 is left child of node1, if node2 <> |
| Make the pointer aligned to a 4 byte boundary in a efficient manner Posted: Assign the pointer to a long number and the number with 11…1100 add 4 to the number |
| Write a program to remove duplicates from a sorted array. Posted: int remove_duplicates(int * p, int size) { int current, insert = 1; for (current=1; current <> |
| Posted: Scan array in pairs. Remember largest-so-far and smallest-so-far. Compare the larger of the two strings in the current pair with largest-so-far to update it. And the smaller of the current pair with the smallest-so-far to update it. For a total of |
| Posted: If numbers are in 2s complement, an ordinary looking loop like for(i=total=0;i<> |
| Posted: [Is there an O(n) time solution that uses only O(1) extra space and does not destroy the original array?] |
| Given an array of integers, find the contiguous sub-array with the largest sum. Posted: Can be done in O(n) time and O(1) extra space. Scan array from 1 to n. Remember the best sub-array seen so far and the best sub-array ending in i |
| Posted: Context switches, excessive buffer copying. Optimize by communicating through shared memory on same machine, bypassing the kernel. |


