1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Assoli18 [71]
3 years ago
15

1. Let L be a list of numbers in non-decreasing order, and x be a given number. Describe an algorithm that counts the number of

elements in L whose values are x (English description 5 points + Pseudocode 5 points). For example, if L = {1.3, 2.1, 2.1, 2.1, 2.1, 6.7, 7.5, 7.5, 8.6, 9.0} and x = 2.1 then the output of your algorithm should be 4.
Mathematics
1 answer:
e-lub [12.9K]3 years ago
8 0

Answer:

Algorithm

Start

Int n // To represent the number of array

Input n

Int countsearch = 0

float search

Float [] numbers // To represent an array of non decreasing number

// Input array elements but first Initialise a counter element

Int count = 0, digit

Do

// Check if element to be inserted is the first element

If(count == 0) Then

Input numbers[count]

Else

lbl: Input digit

If(digit > numbers[count-1]) then

numbers[count] = digit

Else

Output "Number must be greater than the previous number"

Goto lbl

Endif

Endif

count = count + 1

While(count<n)

count = 0

// Input element to count

input search

// Begin searching and counting

Do

if(numbers [count] == search)

countsearch = countsearch+1;

End if

While (count < n)

Output count

Program to illustrate the above

// Written in C++

// Comments are used for explanatory purpose

#include<iostream>

using namespace std;

int main()

{

// Variable declaration

float [] numbers;

int n, count;

float num, searchdigit;

cout<<"Number of array elements: ";

cin>> n;

// Enter array element

for(int I = 0; I<n;I++)

{

if(I == 0)

{

cin>>numbers [0]

}

else

{

lbl: cin>>num;

if(num >= numbers [I])

{

numbers [I] = num;

}

else

{

goto lbl;

}

}

// Search for a particular number

int search;

cin>>searchdigit;

for(int I = 0; I<n; I++)

{

if(numbers[I] == searchdigit

search++

}

}

// Print result

cout<<search;

return 0;

}

You might be interested in
the problem is kamala had 5,026 grams  flour in a canister.she brought a 4,158 gram bag of flour.she poured some flour from the
andrey2020 [161]
Hello, 

x= amount of flour that she poured in the canister

there was 5,026 grams of flour, and now: 5,026+x

In the bag there was 4,158, now: 4,158

I says that as a result the mass of the flour in the canister is twice the mass of the flour left in the bag, so:

5,026+x=2*(4,158-x) \\ 5,026+x=8,316-2x \\ 3x=8,316-5,026 \\ 3x=3,290 \\ x=1,096.67

So, she poured 1,096.67 grams, we subtract this from the initial amount in the bag and we have the answer:

4,158g-1,096.67=\boxed{3,061.33}

Answer: there is 3,061.33 grams of flour in the bag
8 0
3 years ago
The tread life of a particular brand of tire is a random variable best described by a normal distribution with a mean of 60,000
valina [46]

Answer: 61,750 miles

Step-by-step explanation:

Given : The p-value of the tires to outlast the warranty = 0.96

The probability that corresponds to 0.96 from a Normal distribution table is 1.75.

Mean : \mu=60,000\text{ miles}

Standard deviation : \sigma=1000\text{ miles}

The formula for z-score is given by  : -

z=\dfrac{x-\mu}{\sigma}\\\\\Rightarrow\ 1.75=\dfrac{x-60000}{1000}\\\\\Rightarrow\ x-60000=1750\\\\\Rightarrow\ x=61750

Hence, the tread life of tire should be 61,750 miles if they want 96% of the tires to outlast the warranty.

3 0
3 years ago
I need help asap!! please!!
andre [41]
Wouldnt it be a dot on the line right in between 75 and 76 pointing towards the left? im not sure 
4 0
3 years ago
Read 2 more answers
WHat is 9 times 8 times 7 times 6 times 4 times 3 times 2 times 1 divided by 8. First person to answer get a free like and brain
AnnyKZ [126]
9072 is the correct answer.
4 0
3 years ago
Read 2 more answers
Dr. Newton is saving up to buy a car. She has already saved $3,000. If she wants to spend
Nuetrik [128]

Dr. Newton needs 5000 dollars, and 3000 dollars have already been saved. So, 2000 dollars remain.

If these 2000 dollars must be saved withint 8 months, we can divide the amount needed by the time given, to find out that Dr Newton needs to save

\dfrac{2000}{8}=250

dollars each month.

4 0
3 years ago
Other questions:
  • Tom has a circular clock with a circumference of 39.88.what is the radius of tom clock, to the nearest hundredth of an inch
    15·1 answer
  • Please help solve the problem!
    14·1 answer
  • Abe goes to a shoe store and finds a coupon offering buy one shoe get one half off. If he finds 2 pairs of shoes that each cost
    11·1 answer
  • The revenue for a company producing widgets is given by y = -20x2 - 50x + 200, where x is the price in dollars for each widget.
    15·2 answers
  • What is the greatest common factor??
    6·2 answers
  • Answer both please......
    6·1 answer
  • Which equation uses the distributive property to simplify the following? 6 × (10 + 0.09)
    14·1 answer
  • Help help due in today
    13·1 answer
  • Please help me !!!!!! please
    9·1 answer
  • 85,86,89,35,60,57,89,75,65​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!