| Other C++ Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| How reader and writer problem was implemented and come up
with effective solution for reader and writer problem in
case we have n readers and 1 writer.
| NetApp | 1 |
| hello friends, given an expression we have to remove the
unwanted brackets in that expression.
Eg : (a+b) ---> a+b
(a+b)*(c)-----> (a+b)*c. Please mail me if you know
the logic. My mail id is : saravana6m@gmail.com.
Thank you in advance :-) | Microsoft | 1 |
| Algorithm in O(2n)
Presently we can solve in our hypothetical machine problem
instances of size 100 in 1 minute using algorithm A, which
is a O(2n). We would like to solve instances of size 200 in
1 minute using algorithm A on a new machine.
What is the speed of the new machine should be? | Qatar-University | 2 |
| what is the use of using for loop as "for(;;)"? | | 3 |
| how to find out the maximum number out of the three inputs. | HP | 3 |
| Coin Problem
You are given 9 gold coins that look identical. One is
counterfeit and weighs a bit greater than the others, but
the difference is very small that only a balance scale can
tell it from the real one. You have a balance scale that
costs 25 USD per weighing.
Give an algorithm that finds the counterfeit coin with as
little weighting as possible. Of primary importance is that
your algorithm is correct; of secondary importance is that
your algorithm truly uses the minimum number of weightings
possible.
HINT: THE BEST ALGORITHM USES ONLY 2 WEIGHINGS!!! | Qatar-University | 1 |
| Counting in Lojban, an artificial language developed over
the last fourty years, is easier than in most languages
The numbers from zero to nine are:
0 no
1 pa
2 re
3 ci
4 vo
5 mk
6 xa
7 ze
8 bi
9 so
Larger numbers are created by gluing the digit togather.
For Examle 123 is pareci
Write a program that reads in a lojban string(representing
a no less than or equal to 1,000,000) and output it in
numbers.
| | 4 |
| what is the best algorithm to sort out unique words from a
list of more than 10 million words(1 crore+)?
we need the best technique in the terms of execution time. | TCS | 4 |
| Write A C++ Program To Input A Number Between 20 To 99 And
Display Its Numbername? | TCS | 2 |
| How do I store linked list datas into an array?
| | 1 |
| Where now stands that small knot of villages known as the
Endians, a mighty forest once stood. Indeed, legand has it
that you could have stoodon the edge of the wood and seen
it stretch out for miles, were it not for the trees getting
in the way.
In one section of the forest, the trees stood in a row and
were of hight from 1 to n, each hight occurring once and
once only.
A tree was only visible if there were no higher trees
before it in the row.
For example, if the heights were 324165, the only visible
trees would have been those of height 3,4 & 6.
Write a Program that takes an array of integers
representing the heights of the trees in the row as input
and prints the list of the visible trees.
| Nagarro | 2 |
| what is the difference between int &r and int& r | | 3 |
| What is the time complexity T(n) of the following program?
a)
int n, d, i, j;
cin >> n;
for (d=1; d<=n; d++)
for (i=1; i<=d; i++)
for (j=1; j<=n; j += n/10)
cout << d << " " << i << " " << j << endl;
b)
void main()
{ int n, s, t;
cin >> n;
for (s = 1; s <= n/4; s++)
{t = s;
while (t >= 1)
{ cout << s << " " << t << endl;
t--;
}
}
}
c)
void main()
{ int n, r, s, t;
cin >> n;
for (r = 2; r <= n; r = r * 2)
for (s = 1; s <= n/4; s++)
{
t = s;
while (t >= 1)
{
cout << s << " " << t << endl;
t--;
}
}
}
| Qatar-University | 2 |
| Show by induction that 2n > n2, for all n > 4. | Qatar-University | 2 |
| Wrie a function which returns the most frequent number in a
list of integers. Handle the case of more than one number
which meets this criterion.
public static int[] GetFrequency(int[] list)
| Nagarro | 2 |
| Deriving time complexity of Binary tree and AVL tree, step
by step. | NetApp | 3 |
| Faster Computers
Suppose you have a computer that requires 1 minute to solve
problem instances of size 1000. What instance sizes can be
run in 1 minute if you buy a new computer that runs 1000
times faster than the old one, assuming the following time
complexities T(n) for our algorithm?
(a) T(n) = O(n).
(b) T(n) = O(n3).
(c) T(n) = O(10n). | Qatar-University | 1 |
| Subsets
Write an algorithm that prints out all the subsets of 3
elements of a set of n elements. The elements of the set are
stored in a list that is the input to the algorithm. (Since
it is a set, you may assume all elements in the list are
distinct.) | Qatar-University | 1 |
| Min-Max
Write an algorithm that finds both the smallest and
largest numbers in a list of n numbers and with complexity
T(n) is at most about (1.5)n comparisons. | Qatar-University | 5 |
| A Binary no. is given, we hav to find it's decimal
equivalent. | | 1 |
| |
| For more C++ Code Interview Questions Click Here |