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
Janet manages the security of the database servers at the mortgage company where she works. The servers are Windows Server 2016;
Mariulka [41]

Answer:

encrypted file system (EFS)

Explanation:

The Encrypting File System (EFS) on windows is a Microsoft feature that help store sensitive file or information on a hard disk in an encrypted format so as to protect it from attackers or any other unauthorize individual. The EFS uses a combination symmetric key encryption and public key technology to protect the files, it is then encrypted with a symmetric algorithm known as DESX.

3 0
3 years ago
You have compiled a new kernel using rpm. when you reboot, the new kernel is not the default selection on the boot menu. you use
vredina [299]
First, rpm is RedHat Package Manager. Compilation is done with gcc, the GNU C Compiler.

To add that kernel to grub2's menu, as root you'd need to run:

grub2-mkconfig > /boot/grub2/grub.cfg #redirection is favored by Red Hat

Check out the man page @ man grub2-mkconfig
5 0
3 years ago
Are you allowed to copy and paste answers on brainy to give answers to other people?
Zanzabum
I’m pretty sure you can; or u can also screenshot n send, which is what i usually doooo
7 0
3 years ago
Read 2 more answers
Drag each tile to the correct box.
Arte-miy333 [17]

Answer:

Explanation:

web server= stores text, images, and other media that make up a website

email server= stores and exchanges messages

Proxy server= filters content and stores data for faster access

FTP server= stores and provides files for download

7 0
2 years ago
Read 2 more answers
Does technology make us more alone?
Anika [276]
Both yeah and no, depending on personal opinion
3 0
3 years ago
Other questions:
  • What are the desirable qualities of a Product Vision?
    11·1 answer
  • You are evaluating the bounce rate of your overall website traffic and find that users with a social media referral source have
    9·1 answer
  • Design a hierarchy c hart or flowchart for a program that calculates the current balance in a savin gs account. The program must
    8·1 answer
  • What can you do to manually exclude an individual from a recipient list?
    6·1 answer
  • If the computer has an encrypted drive, a ____ acquisition is done if the password or passphrase is available. a. passive b. sta
    8·1 answer
  • Random number between 0 and 5 (inclusive)
    10·2 answers
  • What is the family access code right now?
    5·1 answer
  • Learning how to use software takes time. So, after customers have learned to use a particular software package, it is easier to
    11·1 answer
  • What is collaboration
    14·1 answer
  • The startup routine runs,when machine boots up is known as​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!