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
Simplify the ratio 11/33 and then give 2 more equivalent ratios
KATRIN_1 [288]
The simplest ratio is 1/3. Equivalent ratios would be 3/9 and 5/15.
4 0
3 years ago
I need help in area it's hard
Fofino [41]
The area is the length times the width. Find area of shapes by counting unit squares. Some shapes will require combining partial square units to find area.<span>  

        For example - </span><span>A rectangle is 5 centimeters long and 4 centimeters wide. What is its area? </span>

Area = Length * width  

The length is <span><span>5</span></span> centimeters. The width is <span><span>4</span></span> centimeters. So the area is <span><span>5 times </span>4</span> square centimeters.

= 20 square centimeters 
4 0
3 years ago
1. What is the formula for Pythagorean Theorem
Debora [2.8K]

Answer:

The formula is a^2 + b^2 = c^2

Step-by-step explanation:

A and B are legs and C is the hypothunisis.

The theorem is used for triangles.

4^2  + 5^2 = c^2

16 + 25 = c^2

41 = c^2

sqr(41) = sqr(c)^2

c = 6.403124237

4 0
3 years ago
PLEASE HELP!! I DO NOT UNDERSTAND THIS ONE BIT. PLEASE RESPOND!
Slav-nsk [51]
Substitute z with 3.
3(4)^3
Cube 4 with 3
3(64)
Multiply 3 and 64
=192
4 0
3 years ago
Find tan(B) in the triangle.<br> Choose 1 answer<br> A 15/8<br> B 8/17<br> C 8/15 <br> D 15/17
erastova [34]
Answer: C
Explanation: tan = opposite/adjacent. 8 is the opposite length from angle B and 15 is the adjacent length from angle B. so tan(B) = 8/15
6 0
3 years ago
Read 2 more answers
Other questions:
  • PLEASE HELP ASAP!!!! 100% CORRECT ANSWERS ONLY PLEASE!!!!
    13·2 answers
  • What is 184% of 600? show work
    13·2 answers
  • What is the answer for this I need it asap
    13·2 answers
  • Find the difference. 9909 - 199
    12·2 answers
  • What are the domain and range of the function?<br> f(x) = ^3 square x - 3
    10·1 answer
  • Find the value of z. A. 141 B. 110 C. 80 D. 100
    15·1 answer
  • 7/8m + 9/10 - 2m - 3/5
    12·2 answers
  • out of 1200 student served at lunch 660 of the students get hamburgers what is the percent of people who got hamburgers ​
    9·1 answer
  • Find the value of of x sin(4x+30)°=cos(-2x+54)°
    9·1 answer
  • Two students were shopping for school supplies. They need spirals which cost x dollars and pens which cost y dollars. One studen
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!