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
melamori03 [73]
2 years ago
6

Given an array arr of type int , along withtwo int variables i and j , write some code thatswaps the values of arr[i] and arr[j]

. Declare anyadditional variables as necessary.
Computers and Technology
1 answer:
nignag [31]2 years ago
4 0

Answer:

Hi! I suppose that no matter the programming language that you need the algorithm, so I will do in pseudo-code.

 

myArray [int] = [1,2,3,4,5,"Hello","World"];

int i = 5;

int j = 2;

// Save the previous value before the swap

aux1 = myArray[i];

aux2 = myArray[j];

// Swap i & j

myArray[j] = aux1;

myArray[i] = aux2;

print(myArray)

// Out : myArray = [1,2,"Hello",4,5,3,"World"]  

Explanation:

The trick is to save in two variables the previous value of the two position before change the array, just like that you can change the array and make the swap without lost the values.

I hope it's help you.

You might be interested in
In a blockchain, each block has a unique hash value which is dependent on the hash value of the previous block in the chain. Wha
pantera1 [17]

Answer: hello your question lacks the required option, below are the missing options

A. The transaction data in the tampered block is deleted, and a copy is created with the same hash value.

B. The hash values of transaction data of subsequent blocks are validated, and the chain is broken.

C. The hash value for the entire block is nullified, creating a domino effect on all subsequent blocks.

D. The hash values of subsequent blocks are updated as soon as they are tampered with, and the chain continues.

answer : The hash values of subsequent blocks are updated as soon as they are tampered with, and the chain continues ( D )

Explanation:

What happens if a transaction data is changed in an earlier existing block in a Blockchain is that the Hash values of subsequent blocks will be updated as soon as they are tampered with and the chain will continue.

Blockchain is a specially design system for recording information, hence any change in data inputted in an earlier existing blocks that changes will automatically be updated as well in all preceding blocks.

4 0
3 years ago
Since the 1960s, there have been five major generations, or cycles, of computing. Which represents those generations in order?
sergiy2304 [10]

Answer:a) Mainframes, miniframes, PCs, desktop Internet computing, mobile computing

Explanation: The hierarchy of the computers or computing are in the generation is:-

  • Mainframe:-designed for the execution of huge data processing , storage and execution.
  • Miniframe:-has similar functioning as the mainframe but on smaller scale and version.
  • Personal computer(PC):-It is designed for the individual purpose and according the need of the user.
  • Mobile computing:-computing that can be done on the mobile phone similar to the computing on the personal computer
  • Internet computing:-the computing of the mobile and computer system with the facility of the internet connectivity.

7 0
3 years ago
Some systems provide file sharing by maintaining a single copy of a file. Other systems maintain several copies, one for each of
Natalka [10]

Answer:

Explanation:

When you have a single copy, a large number of concurrent updates that are supposed to go to a file may result in the user obtaining incorrect information. This incorrect information obtained them leads to the file being left in an incorrect state. When you have a lot of or multiple copies, then storage waste exist and the various copies might happen not to be consistent with respect one other. In summary, what happens is that

a) Using one copy saves space, but also the change might have an effect on all the users.

b) Using multiple copies avoids eliminates the change problem, while creating its own problems, using more space.

3 0
2 years ago
What is the only language a microprocessor can process directly but most programmers almost never write programs in this code?
Phantasy [73]
Assembly language, a.k.a. machine language.
6 0
3 years ago
What are computer engineering algorithms?
Tom [10]
An algorithm<span> is a well-defined procedure that allows a </span>computer<span> to solve a problem. Another way to describe an </span>algorithm<span> is a sequence of unambiguous instructions. ... In fact, it is difficult to think of a task performed by your </span>computer<span> that does not use</span>algorithms<span>.</span>
5 0
3 years ago
Other questions:
  • Suppose we provide a new implementation of the transport layer protocol tcp providing the same functionality using different alg
    14·1 answer
  • Which option allows you to view slides on the full computer screen?
    11·1 answer
  • "As a ____ database management system, Access is particularly powerful because you can enter data once and then retrieve informa
    6·1 answer
  • What is IaaS? For this service model, what are the resources the cloud vendor will provide/manage and what are the resources the
    15·1 answer
  • An index purports to speed data retrieval. you, therefore, index every attribute in each table. select the likely consequence.
    15·1 answer
  • A browser allows you to set preferences for using the browser. These preferences include all of the following except
    7·1 answer
  • Excerpt from "How Prepared Are Students for College Level Reading? Applying a Lexile-Based Approach."
    6·1 answer
  • Please help it’s timed
    5·1 answer
  • If a system contains 1,000 disk drives, each of which has a 750,000- hour MTBF, which of the following best describes how often
    15·1 answer
  • In what medium do web applications operate?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!