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
K +-23 = -100<br>help me
Alex_Xolod [135]

Answer:

-77

Step-by-step explanation:

-77 + -23 = -100

4 0
3 years ago
Order the following number from smallest to largest. <br><br>25, 10, -15, 0, -5​
blondinia [14]

Answer:

-15, -5, 0, 10, 25

Step-by-step explanation:

The highest negative integer would be the smallest number, the the largest positive number would be the largest.

Brainliiest pleaseeeee

4 0
3 years ago
Read 2 more answers
Evaluate -5 - 15 + 4 + 15
dexar [7]

Answer:

Step-by-step explanation:

-5+-15= -20

4+15= 19

-20+19

-1

7 0
3 years ago
Read 2 more answers
Four times the square of a number is thirty-six"
natka813 [3]
Well first do 36 divided by 4, which is 9, then square root 9 to make it 3, so your answer should be 3
5 0
3 years ago
Please Help Will mark Brainliest
ankoles [38]
The answer is “a”.

explanation:
the dot is open and the arrow is pointed to the left.
5 0
2 years ago
Read 2 more answers
Other questions:
  • Hello i really need help, please help me. thank you :(
    8·2 answers
  • What is the surface of a cube with the side lenght of 9cm
    8·1 answer
  • The table shows the relationship y=kk. It’s a constant of proportionality, k?
    5·2 answers
  • Peggy is p years old maggie is 1 year less than 1/4 of peggys age what is maggies age in terms of p
    11·1 answer
  • I needdddd helpppppp
    13·1 answer
  • What is 3/4 divide by 1/6 <br> no simplfly
    6·1 answer
  • a coin is tossed and a die is rolled. Find the probability of tossing a tail and then rolling a number greater than 2
    6·1 answer
  • How to convert 15 cm to mm​
    10·1 answer
  • (2x + 9)<br> (2x - 5)°<br> 86°<br> (x + 3)<br> 1629<br> (x + 39)<br> What is the value of x?
    12·1 answer
  • Can you use a proportion to solve for a missing side length when given two similar triangles?​
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!