| Other C++ Code Interview Questions |
|| Asked @
|write a program that accepts a number and outputs its
equivalent in words.
take note that the maximum input is 3000
|| ||1 |
|. Write a program using two-dimensional arrays that computes
the sum of data in tows and the sum of data in columns of
the 3x3 (three by three) array variable n.
|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
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.
|write a function – oriented program that calculates the sum
of the squares from 1 to n. thus, if the input is 3, the
output is 14
|| ||2 |
|What will be the output-
|what is the use of using for loop as "for(;;)"?
|A research student is given a singly-linked list. Each node
of the list has a color, which is either “Black”
or “White”. He must find if there are more black nodes than
white nodes, or vice versa. His advisor
gives him 5,000Rs to buy a computer to do the work. He goes
to the computer store and finds a
slightly defective computer which costs a mere 3,000Rs. This
computer has the small problem of not
being able to do arithmetic. This means that he cannot use a
counter to count the nodes in the list to
determine the majority color. The computer is otherwise
fully functional. He has the evil idea that he
could buy the defective computer and somehow use it to do
his work, so that he can use the rest of
the money on enjoyment. Show how he can accomplish this
amazing task. Write code for an algorithm
called ‘findMajorityColor’ which takes a singly-linked list,
L, with n nodes and returns the majority color
among nodes of L. This algorithm should have the same
asymptotic running time as counting the
nodes (O(n)). Note: No arithmetic is allowed.
|| ||1 |
|Find the maximum product of three numbers in an array?
Max product= 9*5*3= 135
The array can hav negative numbers also..
|Write an algorithm that receives a string and reverses it.
|| ||2 |
|PROBLEM #8 The cashier at the counter of a Super Store, Mr.
Khazaanchi has the following
bundles of rupee cash notes with him:
Rs. 1, 2, 5, 10, 50, 100, 500, 1000
A customer comes at his counter with various items that he
has shopped. Mr. Khazaanchi totals
the item prices and tells the customer his total amount
payable. The customer gives Mr. Khazanchi
some amount of cash. Find the total number of rupee notes of
each denomination (i.e. 1, 2, 5, 10,
50, 100, 500, 1000) Mr. Khazaanchi will have to give to the
withdrawer ensuring that the total
number of rupee notes are minimum.
|| ||1 |
Write an algorithm that finds both the smallest and largest
numbers in a list of n numbers and calculate its complexity
|Deriving time complexity of Binary tree and AVL tree, step
|For more C++ Code Interview Questions Click Here |