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
find the measure of the vertex anlge of an isosceles triangle if the measure of one base angle is 36°
atroni [7]
Because it is an isosceles triangle, the two base angles have to be the same, so
36°+36°=72°
angles in all triangles add up to 180°, so
180°-72°=108°
unknown=108°
5 0
3 years ago
The number of calories Kira burns while riding a bike varies directly with the number of hours the bike is ridden. How many calo
Veseljchak [2.6K]

480 since 1 hour=60 minutes.  Look on the graph and you can see that the line looks like its 500 but since the answer choices dont say 500 it has to be 480 which is the closest


4 0
3 years ago
Joel is making sauces at his restaurant.He has 8 gallons of chicken broth. He puts it into 5 pots so each has the same amount. H
GarryVolchara [31]

Answer:1 r3

Step-by-step explanation:8 Divided by five

4 0
3 years ago
What is the probability that a point chosen at random in the rectangle is also in the blue triangle?
andrew-mc [135]

Answer:

<h2>1/2</h2>

Step-by-step explanation:

there are 2 corners that are blue out of 4

2/4 is the same as 1/2

3 0
2 years ago
Pls hurry , timed test
Vesnalui [34]

Answer:

c

Step-by-step explanation:

4 0
2 years ago
Other questions:
  • What is the reciprocal of -b/3
    8·1 answer
  • Imagine a 10 kg chunk of aluminum (density = 2.7 g/cm3) and a 10 g chunk of iron (density = 7.9 g/cm3).
    10·2 answers
  • Find the graph of the inequality y &lt; - 3/4 x + 2
    9·1 answer
  • There are 40 boys in the club. the ratio of girls to boys is 2 to 5. how many girls are in the club
    9·1 answer
  • A map measuring 60 cm by 25 cm is reduced twice in the ratio 3:5. Calculate the final dimensions of the map.
    12·1 answer
  • The model below represents the equation 4a = -20
    6·1 answer
  • What is the solution set of {x | x &lt; -5} ∩ {x | x &gt; 5}?
    10·1 answer
  • Calvin earned $1,425 dollars by working five days in a week . He also received a bonus of $200.What is the average amount that h
    12·1 answer
  • Fahim is 6 feet tall. At noon, he stands with the sun behind him casting a shadow. The distance from the top of Fahim’s head to
    6·2 answers
  • A study conducted by the Center for Population Economics at the University of Chicago studied the birth weights of 614 babies bo
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!