| Other C++ Code Interview Questions |
| |
| Question | Asked @ | Answers |
| |
| 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 |
| 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 |
| A Binary no. is given, we hav to find it's decimal
equivalent. | | 1 |
| 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 |
| 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 |
| 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 |
| 1.program to add any two objects using operator overloading
2.program to add any two objects using constructors
3.program to add any two objects using binary operator
4.program to add any two objects using unary operator | | 1 |
| using repetition structure. Write a c program that will
accept five numbers. The program should count and output the
total count of even numbers and total count of add numbers.
| | 2 |
| Min-Max
Write an algorithm that finds both the smallest and largest
numbers in a list of n numbers and calculate its complexity
T(n).
| Qatar-University | 1 |
| what is the difference between int &r and int& r | | 3 |
| How do I store linked list datas into an array?
| | 1 |
| 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 |
| 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 |
| what is the use of using for loop as "for(;;)"? | | 3 |
| Show by induction that 2n > n2, for all n > 4. | Qatar-University | 2 |
| how to find out the maximum number out of the three inputs. | HP | 3 |
| what is virtual constroctor ? give an exam for it?-(parimal
dhimmar) | | 2 |
| Write A C++ Program To Input A Number Between 20 To 99 And
Display Its Numbername? | TCS | 2 |
| Complexity T(n)
Write a linear-time algorithm that sorts n distinct
integers, each of which is between 1 and 500.
Hint: Use a 500-element array. (Linear-time means your
algorithm runs in time c*n + b, where c and b are any
constants that do not depend on n.
For example, your algorithm can run in time n, or time 2n +
1, or time 5n + 10, or time 100n + 6, but not time c*n*n =
c*n?.) | 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 |
| |
| For more C++ Code Interview Questions Click Here |