Number of moves:
you are given a nxn square chessboard with one bishop and k number of obstacles placed on it. A bishop can go to different places in a single move. find the total no.of places that are possible for the bishop in a single move. Each square is referenced by a type describing the row, R, and column, C, where the square is located.
explanation: given N=6 K=2
bishop position 5 2
obstacle positions (2 2), (1 5)
the bishop can move in so o/p is 6
I/p:
6 2
5 2
2 2
1 6
O/p:
6
I/p:
6 4
3 3
1 3
3 1
5 1
1 5
O/p: 7
(For Questions 2 to 5)
Consider the function f(x) = x^3−2x^2−4x+ 2.
Question 3
Which of the following statements is true about the given function?
(1) The Intermediate Value Theorem does not hold between x = −1 and x = 1.
(2) The function has two roots in the interval [−2, 4].
(3) It will take at least 15 iterations of the bisection method to approximate the root between
x = −2/3 and x = 2 correct to 10^−4.
(4) It will take no more than 14 iterations for the bisection method to converge to the root between
x = −2/3 and x = 2 correct to 10^−5.
(5) The function has at least one singular point.
(For Questions 2 to 5)
Consider the function f(x) = x^3−2x^2−4x+ 2.
Question 2
Which of the following statements about the given function is FALSE?
(1) the graph of the function has one point of inflection and has two relative extrema.
(2) The function has no absolute extremum.
(3) The graph of the function has two roots in the interval [0, 3.5]
(4) The function has a point of inflection point at x = 0.
(5) The function has a relative maximum point at x =
−2
3
and relative minimum point at x = 2.
Question 1
To have an idea on whether we should apply the bisection method to determine the root of f(x) = 0
in a given interval, we may
(1) draw the graph of f(x) and observe the graphs then conclude
(2) check if f(x) and f'(x) are continuous then conclude
(3) apply the function f(x) to the endpoints of the given interval and check the sign of the corre-
sponding outputs.
(4) check if f(x) has a critical point in the given interval
(5) check if f(x) has a point of inflection in the given interval.
Write a c++ program using string function that will accept the course
abbreviation as input value and it will display the corresponding
college.
Write a C++ function in which it reads namesfrom file “data.txt” into character array and remove
the repeating names. Write your updated names list in another file called “output.txt”
Example:
Data.txt
Hira
Ali
Ahmad
Imran
Ali
Warda
Annie
Ali
Kinza
Hira
Output.txt
Hira
Ali
Ahmad
Imran
Warda
Annie
Kinza
Ash is now an expert in python function topic. So, he decides to teach others what he knows by making a question on it. Problem statement of his question is as follows.
Your task is to write a function outer_layer(num) that returns function inner_layer, where num is a positive integer. Function inner_layer(div) check whether num is divisible by div or not, its return type is bool (True/ False).
num is of type string
div is of type int and belongs to {2, 5, 9, 10}
Functions are Objects - Since functions are just like variables, they can be returned from a function!
def outer_layer():
print 'This is outer layer'
def inner_layer():
print 'This is inner layer'
return inner_layer
def __name__ == '__main__':
func_obj = outer_layer() # func_obj now becomes inner_layer, and This is outer layer is printed on the screen.
func_obj()
Output:
This is outer layer
This is inner layer
Write a program in C to find out the frequency of elements in an array
1. Using Amdahl’s Law, calculate the speedup gain for the following applications:
· 40 percent parallel with (a) eight processing cores and (b) sixteen processing cores
· 67 percent parallel with (a) two processing cores and (b) four processing cores
· 90 percent parallel with (a) four processing cores and (b) eight processing cores
Write a c++ program using string function that will accept the course
abbreviation as input value and it will display the corresponding
college.