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
Vlad [161]
2 years ago
10

Write a routine to interchange the mth and nth elements of a singly-linked list. You may assume that the ranks m and n are passe

d in as parameters. Allow for all the ways that m and n can occur. You must rearrange the pointers, not simply swap the contents.
Computers and Technology
1 answer:
IRINA_888 [86]2 years ago
3 0

Answer:

//The routine to swap m th and nth ranked elements

void swapmAndn(int m, int n)

{

  //Set the linked list head node

  Linked_Node **node_head

  //To find the m ranked node

  //set previous node  

  Linked_Node *node_prev = NULL;

 

  //set node to store m ranked node as head node

  Linked_Node *node_current_m = *node_head;

 

  //set the rank as rm=1

  rm =1

  //traverse to find the m ranked node

  while (node_current_m && rm<m)

  {    

      node_prev = node_current_m;

      node_current_m = node_current_m->next;

      rm++;

  }

 

  //To find the n ranked node

  //set previous node  

  Linked_Node *node_prev_n = NULL;

 

  //set node to store n ranked node as head node

  Linked_Node *node_current_n = *node_head;

 

  //set the rank as rn=1

  rn =1

  //traverse to find the n ranked node

  while (node_current_n && rn<n)

  {    

      node_prev_n= node_current_n;

      node_current_n = node_current_n->next;

      rn++;

  }

 

  //if m is not first ranked node

  if (node_prev != NULL)

      //set node_current_n as previous node

      node_prev->next = node_current_n;

 

  //otherwise Set the node_current_n

  else

      *node_head = node_current_n;

 

  // If n is not first ranked node

  if (node_prev_n!= NULL)

      node_prev_n->next = node_current_m;

  else

      *node_head = node_current_m;

 

  //now swap the next pointers also

  //to make the swap process complete  

  Linked_Node *temp = node_current_n->next;

  node_current_n->next = node_current_m->next;

  node_current_m->next = temp;

}

Explanation:

You might be interested in
There are many modes of remote visual communication. which is the most common mode
Veronika [31]
The answer is mobile communication, this consists of emails, texts, and parts of social media (Ex. DM's)
7 0
2 years ago
Why might a company choose Linux for its operating system instead of Microsoft Windows or Mac OS? The company's employees can sy
insens350 [35]

Answer:

D.

The company can create an operating system to fit its specific needs.

Explanation:

Linux is an open source operating system format, which can be modified to fit specific needs of it's users.

6 0
2 years ago
Your friends know that you understand a lot about computers, both the technical details of how they operate as well as informati
erma4kov [3.2K]

Answer:

The answer is A.

Explanation:

Regarding the information given in the question, we are asked to evaluate the options given which i believe have answers as follows;

B is true. Public-domain means that there are no individuals who hold a copyright over the subject which enables people to copy and distribute, the software in this case, freely.

C is true. Shareware is a term that is used for applications which have a certain trial period for users to decide whether the application meets their needs and demands and then they have to pay the required amount to keep using the software to its full potential. Most often it is the case that if the user does not agree to a payment, the features they are allowed to use are very limited and render the software almost useless until the payment is completed.

D is true. "Copyright" is by definition is approved by the authorities and gives its creater the right to use, sell and change the creative product as they please. It works the same way for software products as well so the statement in option D is true.

A is wrong. Although they are freeware, this softwares still may have copyrights and even if they do not, they are very basic or even incomplete programs to satisfy the minimal needs of its users.

I hope this answer helps.

7 0
3 years ago
Suppose that the domestic production of computer games creates enjoyment for those who play the games. Domestic production of co
kirill [66]

Answer:

a

Explanation:

Based on the information provided within the question it can be said that the best possible policy to encourage this would be to impose tariffs on computer game imports. This would force company's to begin domestic production of computer games in order to continue making the profits from the domestic market as opposed to losing out on all of the opportunities that the domestic market offers them.

6 0
2 years ago
A while loop should be used if you want the user to watch the same video three times.
Ghella [55]

Answer:

false

Explanation:

7 0
2 years ago
Other questions:
  • How i can connect to internet automatically when i switch on my computer?
    8·1 answer
  • What is unique about being an administrative professional in a government job?
    8·2 answers
  • What is the very first thing a user usually must do to gain access to a secure computer?
    7·1 answer
  • _____ is the widely used transport layer protocol that most Internet applications use with Internet Protocol (IP).
    9·1 answer
  • What are the pros and cons of using a linked implementation of a sparse matrix, as opposed to an array-based implementation?
    11·1 answer
  • Your marketing director at ABC Marketing Agency would like to set up an email campaign that will use personalization to referenc
    5·1 answer
  • What happens if the user sysadmin invokes the mail command interface and there are no unread mail messages?
    13·1 answer
  • Why does every image on brainly look like this too me?? it started today
    15·2 answers
  • In PowerPoint, a picture might be a photograph, a shape you draw, a piece of clip art, or an illustration created using a graphi
    7·2 answers
  • What is the difference between the wiring configurations for a residential, 8-position, 8-contact (8P8C) modular plug and jack i
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!