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
pashok25 [27]
3 years ago
5

Write a function insert that takes an array of integers in ascending order, the number of integers currently in the array, the t

otal size of the array, and an integer to insert into the array. The function should insert the given integer into the array such that the array remains in sorted order. If the array is already full, the array should remain unchanged. The function should return the new number of elements in the array.
Computers and Technology
1 answer:
Andrei [34K]3 years ago
3 0

Answer:

The code is written in MATLAB

function insert(array,integer,capacity,newInt)

if integer == capacity %if the array is full, the function returns the original array

result = array;

else

if newInt < array(1) %If the new integer is less than the first element, it copies the new integer as the new first element

array = [newInt array];

elseif newInt > array(end) %If the integer is greater than the last element, it copies the new integer as the new last element

array = [array newInt];

else %If the new integer is inside the array, then it checks its new place

for i = 1:length(array)-1

if array(i+1) > newInt % once the place of the new integer is found, the rest of the array is saved in a dummy array

dummy = array(i+1:end);

array(i+1) = newInt;

array(i+2:end) = '';%the rest of the array is deleted

array = [array dummy]; %concatanate the dummy array with the newInteger inserted array

break

end

end

end

end

fprintf('The inserted integer is %g\n', newInt);

fprintf('The new array is \n',array);

disp(array)

You might be interested in
Convert 12 bits to bytes​
Genrish500 [490]

Answer:

1.5 bytes

Explanation:

I byte = 8 bit ....

3 0
2 years ago
The Appliance Warehouse case study is designed to practice systems analysis and design skills using a life-like scenario. Applia
nikdorinn [45]

Answer:

A service department that I would create for a product from Appliance Warehouse is:

The washing machines service department.

Explanation:

Appliance Warehouse is one of the most important if not the most important washer and drying machine leasing company. So, they require a very good service department for them. Thus, I would develop one very innovative service department with an online application that would allow performing this job with an outsourcing labor force making it cheaper or us. The recruitment would be based on the different washing machine brands certification as a service and repair provider technician. We would also select them based on consumer service orientation and will create a database on the platform. This platform would be categorized by county, let us offer it for our selected local service outsource technicians. We would make an agreement with them for the database in the form of a services contract that would set a diagnosis and a services fee. We would also have an inventory of machine parts and we would only charge 20% of the cost of the services. We would establish the fee and we would also sell the costumer the fee for the parts used to fix the machines.  

6 0
3 years ago
Write a C++ programthat simulates a cash register. The user should keeptyping
-Dominant- [34]

Answer:

//C++ code for the cash register..

#include <iostream>

#include<vector> //including vector library

using namespace std;

int main() {

vector<float> cash; //declaring a vector of type float.

float item=2,cash_sum=0;

int counter=1;

while(item!=0)//inserting prices in the vector until user enters 0...

{

    cout<<"Enter the price of item "<<counter<<" :"<<endl;

cin>>item;

counter++;

cash.push_back(item);//inserting element in the vector...

}

for(int i=0;i<cash.size();i++)//looping over the vector...

{

    cash_sum+=cash[i];//summing each element..

}

cash_sum*=1.08;//adding 8% sales tax.

cout<<cash_sum;//printing the result....

return 0;

}

Explanation:

I have taken a vector of type float.

Inserting the price of each item in the vector until user enters 0.

Iterating over the vector for performing the sum operation.

Then after that adding 8% sales tax to the sum.

Printing the output at last.

6 0
3 years ago
PLEASE HELP ASAP!!!!!!!!!!!
Bingel [31]

Answer:

True

Explanation:

3 0
3 years ago
Read 2 more answers
Which destination ipv4 address does a dhcpv4 client use to send the initial dhcp discover packet when the client is looking for
Dima020 [189]
<span>A DHCPv4 client use the broadcast IP address to send the initial DHCP discover packet when the client is looking for a DHCP server. </span><span>
A workstation will send a DHCPDISCOVER message to start the process of obtaining a valid IP address. The client  does not know the addresses of DHCP servers, and that's why it sends the message via broadcast, with destination addresses of FF-FF-FF-FF-FF-FF and 255.255.255.255.</span>
5 0
4 years ago
Other questions:
  • Modern operating systems decouple a process address space from the machine’s physical memory. List two advantages of this design
    15·1 answer
  • Why is it best to run antivirus scans when the computer isn't being utilized?
    7·1 answer
  • Consider a bit stuffing framing method where the start of a frame is indicated by 6 consecutive ones, followed by 2 zeroes. What
    8·1 answer
  • What is the output of the following program segment? int main() { int num = 5; cout &lt;&lt; num &lt;&lt;" "; change(num); cout
    8·1 answer
  • Using the triple DES algorithm, which is the cipher text?
    8·1 answer
  • Online transaction processing (OLTP) and online analytical processing (OLAP) are similar MIS strategies used to help with busine
    9·1 answer
  • Which fraction represents the shaded part of this circle? 1 2 O 4 Check Answer /3rd grade/​
    14·2 answers
  • What is the output of the code?
    15·1 answer
  • Write Java code that creates an array of n integers myArray, by taking n integers from the user with duplications, and do the fo
    8·1 answer
  • Ethan is afraid that his poor grades will get him kicked out of his university at the end of the semester. He decided to remotel
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!