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
If the pattern in the table continues when will sales for DVD players equal sales for mobile phones?
omeli [17]

Answer:

<em>never </em>because they are continually increasing at the same rate without multiplying and dividing

3 0
3 years ago
Write an algebraic equation to represent the situation.
KatRina [158]

3(x+1) = regular cheese burger

6 0
3 years ago
Please help im stuck on this one i font know how to do inverse operarions​
Goshia [24]

Answer:

107.500

Step-by-step explanation:

5.450.000-75.000=5.375.000

5.375.000:12 1/2=5.375.000:25/2=5.375.000*2/25=430.000

430.000:4=107.500

+ and - ,

*  and :

are inverse  operations

Where it is an operation and the result is a number , we have to do the inverse operation for finding the initial number.

verifying :

107.500*4*12 1/2+75.000=5.450.000

5 0
4 years ago
Can anyone help me out with #7. It's proofing. The reasoning part is most confusing to me
nikklg [1K]
The two large triangles can be proven congruent through SSS ASA and SAS, you have all the congruent angles and sides you could ever need to prove the two large triangles congruent in at least 3 ways
5 0
3 years ago
Simplify (a3b-6/a-3 b 3)1/2
o-na [289]

This is the answer. Let me know if i'm correct.

3 0
3 years ago
Other questions:
  • SOME HELP!!! PLEASE ASAP EXTRA POINTS I NEED THIS DONE RIGGHT NOW PLEASE!!!!!!!!!!!!
    15·1 answer
  • What is the inverse of the logarithmic function
    14·1 answer
  • Suppose that the given line has a slope of -2/3 and a y-intercept of (0,5/3). which of the following points is also a solution t
    13·1 answer
  • The area of a rectangle is expressed as (12m + 18) square feet. If the width of the rectangle is 6 feet, choose an expression to
    15·2 answers
  • 25 units 5 units x units​
    10·1 answer
  • What is the rate of change of the function y - 6x + 3?​
    6·2 answers
  • A pipe is located 45 feet below sea level. What integer would represent the location of the
    8·1 answer
  • SOMEONE HELP ME PLEASE!!!
    15·1 answer
  • Please help I don't understand​
    7·1 answer
  • A square is inscribed in a circle. How much larger is the area of the circle than the area of the square?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!