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]
3 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]3 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
Janice, who is 15, posts post a picture of herself drinking alcohol and making an obscene gesture on her social network page. wh
mars1129 [50]

answer

A and B

Explanation.

A and B are the answers because this a real life scenario.

it's also can ruin her dreams on going to college to get a degree on what she want's to be and job application on her degree or any kind of job.

8 0
3 years ago
Read 2 more answers
Which of the following is most likely to include technical vocabulary?
Step2247 [10]
<span>C. a scientific article</span>
6 0
3 years ago
While a threat intelligence analyst was researching an indicator of compromise on a search engine, the web proxy generated an al
inna [77]

Answer: the corret answer C. The analyst has prefetch enabled on the browser in use.

Explanation:

The analyst has like an indicator which is prefetch enabled on the browser in use.

7 0
3 years ago
You type a complex formula in cell A20. You would like to make the same calculation in cells B20 through H20. To be efficient, y
fomenos

Answer:

Use autofill

Explanation:

In excel "autofill" is used to fill data in cells, which follows the pattern or logic applied in other cells. To apply same calculation of A20 in B20 to H20, we use autofill technique. Instead of copy pasting, or manually entering the complex formula this method is more suitable.  

4 0
3 years ago
Which is said to be ‘computer on a chip’ (a) Micro processors (b) Microcontrollers (c) Both (c) None of the above
fiasKO [112]
I think the answer would be A
5 0
3 years ago
Other questions:
  • I want to customize my company's logo, name, address, and similar details in all my business documents what option should use?
    12·1 answer
  • What can a parent do to help a child adjust to a new culture or area
    7·2 answers
  • A method's name and parameter list constitute the method's ____.
    13·1 answer
  • Write a Program in C language using arrays:
    14·1 answer
  • If we want to access files located in a directory on a remote server, which of these options would we use?
    9·2 answers
  • Explain the bad effect and good effect of mobile phone and internet.<br>​
    15·2 answers
  • Give an essay on a way I can be a better person. If not correct I will refund. Best answer gets brainiest. Detailed, 5 sentience
    10·2 answers
  • Most case fans have standard _______________ connectors that are easy to plug in but can be forced to be connected the wrong way
    14·1 answer
  • Identify the network and the host address in the ip address of 12.128.120.131 with a subnet mask of 255.128.0.0.
    6·1 answer
  • write a function named get majority last name that accepts as its parameter a dictionary from strings to strings the keys of the
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!