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
VikaD [51]
2 years ago
9

Given a sorted array of integers created on the heap, its size and a new integer, design a function which will enlarge the array

and place the new item in the appropriate position in the array, so that it remains sorted. c++
Computers and Technology
1 answer:
Debora [2.8K]2 years ago
7 0

Using the computational language in C++ to write a code that will organize the values ​​in an array through a mathematical condition.

<h3>writing code in C++</h3>

<em>#include <bits/stdc++.h></em>

<em>using namespace std;</em>

<em>int getIndexInSortedArray(int arr[], int n, int idx)</em>

<em>{</em>

<em>/* Count of elements smaller than current</em>

<em>element plus the equal element occurring</em>

<em>before given index*/</em>

<em>int result = 0;</em>

<em>for (int i = 0; i < n; i++) {</em>

<em>if (arr[i] < arr[idx])</em>

<em>result++;</em>

<em>if (arr[i] == arr[idx] && i < idx)</em>

<em>result++;</em>

<em>}</em>

<em>return result;</em>

<em>}</em>

<em>int main()</em>

<em>{</em>

<em>int arr[] = { 3, 4, 3, 5, 2, 3, 4, 3, 1, 5 };</em>

<em>int n = sizeof(arr) / sizeof(arr[0]);</em>

<em>int idxOfEle = 5;</em>

<em>cout << getIndexInSortedArray(arr, n, idxOfEle);</em>

<em>return 0;</em>

<em>}</em>

See more about C++ at brainly.com/question/12975450

#SPJ1

You might be interested in
If you wanted to create a line of code that would add ten to the user’s current score, which code should you use?
Korvikt [17]

Answer:

choice c

Explanation:

score = score + 10

because the rest doesn't make since and score == score + 10 has an extra equal sign.

7 0
3 years ago
Read 2 more answers
Cheri needs to write a small program that interacts with the user. What step will allow her to do this?
Alinara [238K]

Answer:

Including a input statement

Explanation:

You need a input statement in order for it to work, here´s an example;

script.parent.click <u>then</u>

you need the ¨.mouse¨ after parent or it wouldnt work.

8 0
3 years ago
Read 2 more answers
Write a function solution that given an array a of n integers (between -100 and 100), returns the sign (-1,0,1) of product of al
JulijaS [17]

left[0]=a[0];

for(int i=1;i<=n-1;i++)

   left[i]=(left[i-1]*a[i])%M;

right[n-1]=a[n-1];

for(int i=n-2;i>=0;i--)

   right[i]=(right[i-1]*a[i])%M;

for query q

   if(q==0)

       return right[1]%M;

   if(q==n-1)

       return left[n-2]%M;

   return (left[q-1]*right[q+1])%M;

4 0
2 years ago
NEED HELP PLEASE-
zysi [14]

Answer:i believe it is patents. i could be wrong

Explanation:

To protect your interests, consider two common strategies employed by inventors, amateur and professional alike. First, you can file a provisional patent application (if your invention is patent able)

5 0
3 years ago
Read 2 more answers
How do you render and export files on blender
Debora [2.8K]

Answer:

Save your Blender file (. blend) in the same folder as your . obj file, if you didn't already.

Click on File/External Data/Pack All into . blend.

Click on File/External Data/Unpack All Into Files.

Choose "Use files in current directory (create when necessary)"

Explanation:

<em>Hope </em><em>it </em><em>helps </em><em>ya </em><em>ItzAlex</em>

6 0
3 years ago
Other questions:
  • When looking to ensure your website is easily accessible by mobile users, what should you focus on doing first
    8·1 answer
  • Which of the following statements is NOT true about a mainframe computer?
    14·1 answer
  • Which feature of the Excel window should I use to perform an action
    11·1 answer
  • What does this image represent?
    9·2 answers
  • Type the correct answer in the box. In which phishing technique are URLs of the spoofed organization misspelled? _____ is a phis
    11·1 answer
  • When a workforce scheduling problems is formulated as an integer programming model, it has:?
    6·1 answer
  • Which statement does not describe how to save a presentation?
    11·1 answer
  • Define the terms of data and information .​
    6·1 answer
  • No down payment, 18 percent / year, payment of $50/month, payment goes first to interest, balance to principal. Write a program
    9·1 answer
  • What is the role of the memory in a computer ​
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!