Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

(a) Write a function called count to determine the number of times a specific value
occurs in a vector of integers. The function should receive two parameters: the
vector to be searched (v) and the value to search for (val). count should return
the number of times val occurs in vector v.
Test your function count in a program by declaring a vector and initializing it, and
then call function count to determine how many times a specific value occurs in
the vector.
(b) Write a template version of the function count to determine the number of times
a specific value occurs in a vector of any base type and test it by declaring two
or more vectors with different base types and determining how many times a
specific value occurs in these two vectors.
What is the value of pairs after the following assignment?
pairs = [ (x,y) for x in range(5,1,-1) for y in range(4,1,-1) if (x+y)%3 == 0 ]

Flow control is one of the main building blocks that determines how a program should run. Ghana Cocoa Growing company wishes to compare the impart of two newly acquired fertilizers on cocoa. They will do this by applying the same quantity of the two fertilizers on two similar but different cocoa plant under the same conditions (humidity, sunlight, soil moisture etc.). They will then choose the fertilizer whose crop produces the best harvest (highest quantity per square feet). As a programmer, 

 

a. Suggest a flow control method that would be used to do the comparison and explain the reason why you chose it.   

b. Write a flow control statement that would do the comparison in “a” above. 



Take ‘n’ historic sites in Tamil Nadu as input. Design and implement a code in c language using brute force approach that identifies the shortest possible route for a traveller to visit these sites and come back to his starting point.


write a program for Strassen’s matrix multiplication algorithm using divide and conquer approach in c language.


Problem 3: In the country of WeirdLand, there is only one barber shop. In the shop there are 3 barbers, Alpha, Beta and Gamma, who are not always efficient as employees. All the customers are seated in a waiting area, each customer has a card which has a unique integral ID. For calling next person from the waiting area each barber has his own weird way: Alpha: He will call either the person with least ID from the waiting area of the one with max ID. Min or Max is decided randomly by him (assume 50% probability for each min or max). Beta: He will choose a ‘k’ and will call the kth smallest ID, (Kth ID when all IDs are arranged in ascending order). K is chosen randomly from the number of persons available in waiting area (1 <= K <= Total persons)


In the country of WeirdLand, there is only one barber shop. In the shop there are 3

barbers, Alpha, Beta and Gamma, who are not always efficient as employees. All the customers are seated in a waiting area, each customer has a card which has a unique integral ID. For calling next person from the waiting area each barber has his own weird way:

Alpha: He will call either the person with least ID from the waiting area of the one with max ID. Min or Max is decided randomly by him

Beta: He will call the kth smallest ID, (Kth ID when all IDs are arranged in ascending order). K is chosen randomly(1 <= K <= Total persons)

Gamma: He will always choose the median ID. If there are ‘n’ people in the waiting area, the median will be defined as (n+1)/2 th ID when all of them are arranged in ascending order. (For both odd and even ‘n’ )

Your task is to design a data structure which should support the query of each of the three

barbers. The data structure should be highly efficient.


In this assignment, let's build a Yoga page by applying the concepts we learned till now. You can use the Bootstrap concepts and CCBP UI Kit as well.




Sum of the series

Write a program to find the sum S of the series where S = x - x^3 + x^5 + ....... upto N terms.

Input

The first line of input is an integer X. The second line of input is an integer N.

Explanation

If we take X value as 2 in the series upto 5 terms.

Then the series is 2 - 23 + 25 - 27 + 29

So, the output should be

410.

Sample Input 1

2

5

Sample Output 1

410

Sample Input 2

3

2

Sample Output 2

-24




Right Angled Triangle - 3

Given an integer number N as input. Write a program to print the right-angled triangular pattern of N rows as shown below.

Input

The first line of input is a positive integer.

Explanation

For example, if the given number is

5, the output should be

______

| /

| /

| /

| /

|/


Sample Input 1

5

Sample Output 1

______

| /

| /

| /

| /

|/

Sample Input 2

7

Sample Output 2

________

| /

| /

| /

| /

| /

| /

|/




LATEST TUTORIALS
APPROVED BY CLIENTS