| Other C++ Code Interview Questions |
|| Asked @
|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.
|what is the difference between int &r and int& r
|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?
|How do I store linked list datas into an array?
|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 : firstname.lastname@example.org.
Thank you in advance :-)
|Given 1 to n random number, find top 10 maximum numbers and
explain the time complexity of the algorithm.
|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”.
Enter 5 numbers: 10 15 20 7 8
Enter number to search: 7
Search number is found!
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.
|program to find the magic square using array
|write a program to calculate the radius for a quadratic
equation use modular programming(function abitraction)hint
use quadratic function
|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..
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...
|Write a program using two-dimensional arrays that determines
the highest and lowest of the 12 input values.
Enter 12 numbers:
13 15 20 13 35 40 16 18 20 18 20 14
|For more C++ Code Interview Questions Click Here |