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
Solve using the elimination method.
densk [106]
Sorry I dont know this answer
7 0
3 years ago
Read 2 more answers
2 x=-80 can u solve this ​
zaharov [31]
Answer
x=-40
hope this helps and have a wonderful day :)
4 0
2 years ago
I need help on a question
schepotkina [342]

Given the figure of a regular pyramid

The base of the pyramid is a hexagon with a side length = 6

The lateral area is 6 times the area of one of the side triangles

So, the side triangle has a base = 6

The height will be:

\begin{gathered} h^2=6^2+(\frac{\sqrt[]{3}}{2}\cdot6)^2=36+27=63 \\ h=\sqrt[]{63} \end{gathered}

so, the lateral area =

6\cdot\frac{1}{2}\cdot6\cdot\sqrt[]{63}=18\sqrt[]{63}

3 0
10 months ago
Help please i need it bad
evablogger [386]

Answer:

-13, -3

15, 2.6

Step-by-step explanation:

x, y are the numbers

x = 5y + 2

x×y = 39

(5y + 2)×y = 39

5y² + 2y - 39 = 0

the solution of a quadratic equation :

y = (-b ± sqrt(b² - 4ac))/2a

a = 5

b = 2

c = -39

y = (-2 ± sqrt(2² - 4×5×-39))/2×5 =

= (-2 ± sqrt(4 + 780))/10 =

= (-2 ± sqrt(784))/10 = (-2 ± 28)/10

y1 = (-2 + 28)/10 = 26/10 = 2.6

y2 = (-2 - 28)/10 = -30/10 = -3

x1 = 5×2.6 + 2 = 13 + 2 = 15

x2 = 5×-3 + 2 = -15 + 2 = -13

5 0
2 years ago
What is the factored form of 49x2 - 56x + 16
OlgaM077 [116]
X = 4/7 = 0.571 I believe so
8 0
2 years ago
Read 2 more answers
Other questions:
  • PLEASE I NEED HELP ASAP! Determine if 9x2 - 42x + 49 can be the area of a square. If so, what would the value of x have to be if
    10·1 answer
  • What is the discriminant of 3x^2-8x+5=5x^2
    5·1 answer
  • If McDonald sells 5 cows for $100 each and buys a horse for $250 how much would he have
    9·2 answers
  • Pls help me with this question
    6·2 answers
  • Write the ratio 42 inches to 9 feet as an fraction
    14·2 answers
  • (6 to the power of 4 times 2) to power of 3. Equivalent expression
    11·1 answer
  • Jon borrows $6.50 from his friends to pay for snacks , and $11.75 from his sister to go to the movies. How much money does he ne
    6·1 answer
  • Using laws of exponents,
    13·2 answers
  • Solve for x. <br><br> HINT: these are exterior angles
    11·2 answers
  • What is the value of x to the nearest degree?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!