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
To rename a worksheet, you change the text on the ? HELP ASAP
prohojiy [21]
If this is Excel, it would be C. Sheet tab
5 0
2 years ago
Which of the following Internet connectivity technologies enables data to be sent over existing copper telephone lines by sendin
Pani-rosa [81]

Answer:

The answer is B. Digital subscriber line technology

Explanation:

Digital subscriber line or DSL technology is used to transmit digital data over telephone wires.

It makes file sharing possible which includes multimedia data (i.e. transfer of pictures and graphics), and also video and audio conferencing.

DSL uses a reliable medium that prevents packet loss and interruptions. It is also fast.

6 0
3 years ago
A _______ is used to analyze and summarize your data without graphical support. A. PivotChart B. PivotTable C. chart D. table
Norma-Jean [14]
B. pivot table................................................
3 0
3 years ago
Write a program that reads a file name from the keyboard. The file contains integers, each on a separate line. The first line of
Sindrei [870]

Answer:

Explanation:

import java.util.Scanner;

import java.io.*;

public class ArrayProcessing

{

public static void main(String[] args) throws IOException

{

Scanner kb = new Scanner(System.in);

String fileName;

System.out.print("Enter input filename: ");

fileName = kb.nextLine();

File file = new File(fileName);

if(!file.exists())

{

System.out.println("There is no input file called : " + fileName);

return;

}

int[] numbers = inputData(file);

printArray(numbers);

}

public static int[] inputData(File file) throws IOException

{

Scanner inputFile = new Scanner(file);

int index = 1;

int size = inputFile.nextInt();

int[] values = new int[size];

while(inputFile.hasNextInt() && index < values.length)

{

values[index] = inputFile.nextInt();

index++;

}

inputFile.close();

return values;

}

public static void printArray(int[] array)

{

int count = 1;

for (int ndx = 1; ndx < array.length; ndx++)

{

System.out.printf("%5.f\n", array[ndx]);

count++;

}

if(count == 10)

System.out.println("");

}

}

4 0
3 years ago
Which of the following tools enables users to connect to a remote computer, including servers with no interaction required from
musickatia [10]

Answer:

Option (A) i.e., Remote Desktop is the correct answer to the following question.

Explanation:

The following option is correct because the remote desktop is an application or software which connects your computer to another system through the internet from anywhere and we can also connect with each other without the internet but in a range.

<u>Steps to connect in Windows 10</u>:

Step-1: Firstly, start your window and click on the start button.

Step-2: Then, type remote setting in search box.

Step-3: Then, you have to allow the remote access to the system.

Step-4: Then, you have select the Remote Tab which appears in System Properties.

Step-5: Then, you have to click and select the to Allow the Remote Connection.

7 0
3 years ago
Other questions:
  • How to make a sad face on keyboard using alt?
    5·2 answers
  • 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
  • What laptop is the best for programming and hacking​
    5·1 answer
  • Many of the first photographers were actullay scientists and inventors
    11·1 answer
  • The national highway system improved economic activity in Georgia by
    6·2 answers
  • Modify the sentence-generator program of Case Study so that it inputs its vocabulary from a set of text files at startup. The fi
    15·1 answer
  • 9. h=
    6·1 answer
  • Question 5 (frue/False Worth 3 points)
    7·1 answer
  • Plsss help me<br>give two examples of problems that can occur when sytems do not work properly​
    9·1 answer
  • Explain why agile methods may not work well in organizations that have teams with a wide range of skills and abilities and well-
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!