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
Point C is located at (1, 2) and point D is located at (-4, -2). Find the X value for the point that is 1/4 the distance from po
kolbaska11 [484]
D (-4; -2)
C (1; 2)
M (x; y)
DM+MC=CD
CM:MD=1:3
M: x= x(C)-(x(C) - x(D))/4=1-(1-(-4))/4=1 - (6/4)=1 - 1,5= - 0,5
M: y=y(C)-(y(C) - y(D))/4=2-(2-(-2))/4=2 - (4/4)=2 - 1=1
M(x; y)=M( -0,5; 1)
8 0
3 years ago
At a school there are five lessons in a day in total the five lessons last 4 hours assume that each session lasts the same amoun
ikadub [295]

Answer:

48 minutes long

Step-by-step explanation:

For a total amount of minutes the lessons are, take 4x60. 4 for the total time in the lessons and 60 for 60 minutes in an hour. 4x60= 240 minutes.

Take 240/5. 240 is the total number of minutes and with the five lessons being the same amount of time, you divide the total number of minutes by the number of lessons. 240/5= 48 minutes

7 0
1 year ago
Please help me with this problem.
masha68 [24]

Answer:

\sqrt{2} is irrational number. It cannot be given as the ratio of two integers.

examples of an irrational numbers: \sqrt{7}, \sqrt{5}, π....

  1. examples of a rational numbers 5,\frac{7}{4}, \frac{1}{1000}....

Step-by-step explanation:

6 0
3 years ago
What is the circumference of the circle below in terms of pie?
asambeis [7]
<span>We have to calculate the circumference of a circle and to choose the correct answer. The circumference of a circle is given by a formula: C = 2 r Pie. In this case radius of the circle is : r = 2.2. Therefore C = 2 * 2.2 Pie = 4.4 Pie. Answer: The circumference of the circle is: D ) 4.4 Pie.</span>
5 0
3 years ago
Read 2 more answers
Match the expressions with the nonpermissible replacements for y
pantera1 [17]

<em>-7 _D_</em>

<em>\frac{3}{2} _A_</em>

<em>1 _C_</em>

<em>\frac{-1}{4} _B_</em>

<em>_A_ \frac{y^{2} -2y+1}{2y-3}</em>

<em>_B_ \frac{y(y+5)}{4y+1}</em>

<em>_C_ \frac{5y^{2}-6y+1 }{-5(y-1)}</em>

<em>_D_ \frac{y^{2}-y-6 }{-2(y+7)}</em>


3 0
3 years ago
Read 2 more answers
Other questions:
  • What is the slope of the line through (-7,-6) and (-2,-5)
    6·1 answer
  • The regular price of an item at a store is p dollars. The item is on sale for 20% off the regular price. Some of the expressions
    5·1 answer
  • Find the circumference of a circle that has a diameter of 4 m. Use 3.14 for pi. m
    5·1 answer
  • What is the ratio of 6/4 in simplest form??
    11·1 answer
  • Your answer is incorrect.
    12·1 answer
  • Nhich equation represents a line that passes through (-9, -3) and has a slope of -6?
    13·1 answer
  • If 2x⁴ + 2y⁴ + 2z⁴ = 144, what is the mean of x⁴, y⁴ and z⁴​
    14·1 answer
  • Question 2
    13·1 answer
  • Write The quotient of fifteen and the product of seven and a number as an equation.
    13·1 answer
  • Please help me with this question &lt;3
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!