Wednesday, April 9, 2008

C++ Basic Tech Interview questions - 7

Basic C++ Computer Language Technical Interview Questions for Freshers / Developers job for Software Company / IT Company

1.Suppose that data is an array of 1000 integers. Write a single function call that will sort the 100 elements data [222] through data [321].
Answer: quicksort ((data + 222), 100);

2. Which recursive sorting technique always makes recursive calls to sort subarrays that are about half size of the original array?
Answer: Mergesort always makes recursive calls to sort subarrays that are about half size of the original array, resulting in O(n log n) time.

3. What is the difference between an external iterator and an internal iterator? Describe an advantage of an external iterator.
Answer: .An internal iterator is implemented with member functions of the class that has items to step through. .An external iterator is implemented as a separate class that can be "attach" to the object that has items to step through. .An external iterator has the advantage that many difference iterators can be active simultaneously on the same object.

4. Why are arrays usually processed with for loop?
Answer: The real power of arrays comes from their facility of using an index variable to traverse the array, accessing each element with the same expression a[i]. All the is needed to make this work is a iterated statement in which the variable i serves as a counter, incrementing from 0 to a.length -1. That is exactly what a loop does.

5.What is an HTML tag?
Answer: An HTML tag is a syntactical construct in the HTML language that abbreviates specific instructions to be executed when the HTML script is loaded into a Web browser. It is like a method in Java, a function in C++, a procedure in Pascal, or a subroutine in FORTRAN.

6.What are the advantages and disadvantages of B-star trees over Binary trees? (Asked by Motorola people)
Ans. B-star trees have better data structure and are faster in search than Binary trees, but it?s harder to write codes for B-start trees.

7.Write the psuedo code for the Depth first Search.(Asked by Microsoft)
Ans.
dfs(G, v) //OUTLINE
Mark v as "discovered"
For each vertex w such that edge vw is in G:
If w is undiscovered:
dfs(G, w); that is, explore vw, visit w, explore from there
as much as possible, and backtrack from w to v.
Otherwise:
"Check" vw without visiting w.
Mark v as "finished".

8.Describe one simple rehashing policy.(Asked by Motorola people)
Ans. The simplest rehashing policy is linear probing. Suppose a key K hashes to location i. Suppose other key occupies H[i]. The following function is used to generate alternative locations:

rehash(j) = (j + 1) mod h

where j is the location most recently probed. Initially j = i, the hash code for K. Notice that this version of rehash does not depend on K.

9.Describe Stacks and name a couple of places where stacks are useful. (Asked by Microsoft)
Ans. A Stack is a linear structure in which insertions and deletions are always made at one end, called the top. This updating policy is called last in, first out (LIFO). It is useful when we need to check some syntex errors, such as missing parentheses.

10. Suppose a 3-bit sequence number is used in the selective-reject ARQ, what is the maximum number of frames that could be transmitted at a time? (Asked by Cisco)
Ans. If a 3-bit sequence number is used, then it could distinguish 8 different frames. Since the number of frames that could be transmitted at a time is no greater half the numner of frames that could be distinguished by the sequence number, so at most 4 frames can be transmitted at a time.

Download free online previous years and latest IT companies technical interview questions with solutions / solved with answers. Complete programs for expert, basic, beginner, advanced, general technical interview questions for Top Software Developers Companies, Experts Jobs for application developers for various computer languages like C, C++, Java, Javascript, Web Designers, Animation companies, Animators, Graphic Designers, Coders, ASP .net, Net, Basic PC and internet / windows questions, etc. for various MNC, MNCs like Infosys, wipro, tcs, satyam computers, hcl, microsoft, google, cisco, web designing studios, mastek, tech mahindra, accenture, IBM etc important, mostly asked questions for freshers, walkin interviews and fully detailed placement question papers.

No comments: