Other C++ Code Interview Questions 

Question 
Asked @ 
Answers 

A research student is given a singlylinked 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 singlylinked 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 
what is the difference between int &r and int& r 

3 
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? 
QatarUniversity 
2 
How do I store linked list datas into an array?


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 
Given 1 to n random number, find top 10 maximum numbers and
explain the time complexity of the algorithm. 
NetApp 
1 
Write a program using one dimensional array that accept five
values from the keyboard. Then it should also accept a
number to search. This number is to be searched if it among
the five input values. If it is found, display the message
“Search number is found!” otherwise, display “Search is lost”.
Example:
Enter 5 numbers: 10 15 20 7 8
Enter number to search: 7
Search number is found!


2 
MinMax
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. 
QatarUniversity 
10 
program to find the magic square using array 

1 
write a program to calculate the radius for a quadratic
equation use modular programming(function abitraction)hint
use quadratic function 
JomoKenyattaUniversity 
1 
a program using one dimensional array that searches a number
if it is found on the list of given input numbers given by
the user and locate its exact location in the list..
""EXAMPLE""
enter how many numbers to be inputted: 5
12 14 11 09 30
what number to search: 11
11 IS FOUND IN LOCATION 3
PLZZZ.. ELP ME...


3 
Write a program using twodimensional arrays that determines
the highest and lowest of the 12 input values.
Example:
Enter 12 numbers:
13 15 20 13 35 40 16 18 20 18 20 14
highest: 40
lowest: 13


1 

For more C++ Code Interview Questions Click Here 