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
What’s the value of a ?
otez555 [7]
The answer is (B)16.
4 0
3 years ago
Which statements about square roots are true? Check all that apply.
Marina86 [1]
Bottom two are true
4 0
3 years ago
Read 2 more answers
From her home, Jada would have to walk 3 miles north to get to her friend Brianna's house and 4 miles east to get to her friend
Yanka [14]

Answer: 12 miles

Step-by-step explanation: Stright from her house to luke is 5 miles back ti brianna is 4 miles and back home is 3 miles all together 5+4+3=12

6 0
3 years ago
Are 5.5 + 2.1x + 3.8x - 4.1 and 1.4 5.9x equivalent
Marat540 [252]

5.5 + 2.1x + 3.8x - 4.1

5.5-4.1 +x(2.1+3.8)

1.4 +x(5.9)

5.9x+1.4

these are equivalent if there is a plus sign between  1.4 5.9x


6 0
3 years ago
Read 2 more answers
"An acute angle is an angle smaller than a right angle."
love history [14]

Answer:

<u>C. definition</u>

<u>Step-by-ste</u>p explanation:

"An acute angle is an angle smaller than a right angle or 90 degrees angle . this is the definition of acute angle

6 0
3 years ago
Other questions:
  • Paul creates the diagram to help him factor 4x2 + x – 5 by using double grouping. His diagram is incomplete. A 2-column table wi
    9·1 answer
  • Factor using a GCF:<br> ​ 16xy2+28xy+8y
    15·1 answer
  • The point (-3/5,y)in the third quadrant corresponds to angle θ on the unit circle.
    9·2 answers
  • * There are five cars in line at a stoplight. Each of these cars is a different color and different type of car. Diego is drivin
    5·1 answer
  • 10 multiplied by 1/5
    7·2 answers
  • Whats 1+5+1+5+1+25x45x65x2,000
    5·1 answer
  • Necesito ayuda por favor es para mañana
    13·1 answer
  • Please help!!!!!
    14·1 answer
  • The ratio
    8·1 answer
  • Maria who is 6 feet tall stand 20 feet away from the base of a tree she looks up at the top of the tree at 43° angle of elevatio
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!