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
Anyone play Ps4 and wanna run up some warzone or Gta? Im M 16 so dont be a creep... :) ill mark brainliest if you drop gamertag
Nikitich [7]

Answer:

Xbox/ PC game here

Explanation:

4 0
3 years ago
Read 2 more answers
A network administrator has statically configured the LMI type on the interface of a Cisco router that is running Cisco IOS Rele
Sergeu [11.5K]

Answer:

The answer is "The LMI model should be compatible with the supplier dynamically for the network manager".

Explanation:

The term LMI stands for the "Local Management Interface", it is a Cisco technology, in which the signaling protocol was used in between routers and transmission frame switches to share data in timekeepers, global addressing, multipathing as well as the present state of virtual socks for various purposes, in which it is mainly used for "dynamically setting, in which the network administrator provides compatibility with the service provider".

8 0
3 years ago
import java.util.ArrayList; // Needed for ArrayList class /** This program demonstrates how to store BankAccount objects in an A
slega [8]

Answer:

import java.util.ArrayList; // Needed for ArrayList class

/** This program demonstrates how to store BankAccount objects in an ArrayList. */

// Class ArrayListDemo6 is defined

public class ArrayListDemo6 {

// main method that begin program execution

public static void main(String[] args) {

// Create an ArrayList to hold BankAccount objects.

// The arraylist is called list

ArrayList list = new ArrayList();

// Add three BankAccount objects to the ArrayList.

list.add(new bankAccount(100.0)); list.add(new bankAccount(500.0)); list.add(new bankAccount(1500.0)); // Display each item using a for loop

for (int index = 0; index < array.size(); index++)

{ BankAccount account = list.get(index);

System.out.println("Account at index " + index + "\nBalance: " + account.getBalance());

}

}

}

Explanation:

The code is written in Java and more comments has been added to make it more explanatory.

The code snippet is a demonstration on Arraylist.

First Arraylist is imported. Then, ArrayListDemo6 class is defined. Then the main method which begin program execution.

Inside the main method, a new Arraylist is created called list.

Then we add three BankAccount object to the list.

Lastly, we use a for loop to display each added BankAccount object.

7 0
3 years ago
04. Suppose a computer program needs to sort a list of student records in ascending order
34kurt

Answer:

D) ["Kathy Bones", "Jill Brewer", "Joe Schnook", "Tom Smith"]

Explanation:

The context of the problem explains a computer program that sorts names in "ascending order" (A to Z) since the ASCII table has capital A start a lower number and it increases from there to capital Z.

Notice how the attached file, which is a portion of the ASCII table, shows that letters after A are also higher in decimal value than the previous letter.

With this in mind, we know that all this program does is sort by last name alphabetical order. From there, just sort the given names using that same criteria, last name alphabetical order, and the correct answer is determined.

<em>Please put "Brainliest" on my answer if it helped you out!</em>

<em>If you want to learn more about this subject, you can search:</em>

<em>- ASCII Table</em>

<em>- Lists in Programming</em>

<em>- Sorting Procedures</em>

7 0
1 year ago
A(n) ____ is software that can be used to block access to certain Web sites that contain material deemed inappropriate or offens
serious [3.7K]

Answer: <em>Internet filter</em>

Explanation:

Internet filters are referred to as software which prevents individuals from accessing certain kind of websites. These filters are predominantly used in order to block content that might be considered inappropriate for some users. These filters are widely used in public library and computers used by schools and colleges.

4 0
3 years ago
Other questions:
  • Question 4 / 5
    11·1 answer
  • Which following is one of the basic characters of object-oriented systems : Select one: a. process b. data c. module d. inherita
    6·1 answer
  • Presses the Schedulr app icon Selects the list item for CSCI 448 Presses the "View Classroom on Map" button While only performin
    11·1 answer
  • A technician removes the cap from the brake fluid reservoir and finds that the rubber boot in the cap is swollen. technician a s
    8·1 answer
  • The administrators of Tiny College are so pleased with your design and implementation of their student registra- tion and tracki
    13·1 answer
  • What would happen if computers only had input devices?
    9·1 answer
  • Here is a list of storage devices:
    5·1 answer
  • BADM-Provide a reflection of at least 500 words (or 2 pages double spaced) of how the knowledge, skills, or theories of this cou
    7·1 answer
  • Which of the following correctly orders the units of measure from least to greatest?
    7·2 answers
  • In Windows, what does the device manager tell you?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!