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
Write the Python code to implement each step of the following algorithm. Your code should use descriptive variable names and per
Lina20 [59]

Answer:

# the number of pizza is initialised

# to 5

number_of_pizza = 5

# number of slice in each pizza

# is initialised to 8

slice_in_each_pizza = 8

# total number of pizza is calculated

total_number_of_slices = number_of_pizza * slice_in_each_pizza

# number of guest who respond yes

# is initialised to 10

number_of_guest_respond_yes = 10

# additional 3 guest is added to existing guest

number_of_guest_respond_yes += 3

# number of left over slice is gotten by using modulo arithmetic

number_of_left_over_slice = total_number_of_slices % number_of_guest_respond_yes

# the number of left over slice

# is printed which is 1

print(number_of_left_over_slice)

Explanation:

Missing Question Part: Use a variable to store the number of pizzas ordered as 5.

Assuming there are 8 slices in each pizza, use a variable to store the total number of slices calculated using the number of pizzas ordered.

Use another variable to store the number of guests who had responded YES as 10.

Three more people responded YES. Update the corresponding variable using an appropriate expression.

Based on the guest count, set up an expression to determine the number of left-over slices if the slices would be evenly distributed among the guests. Store the result of the expression in a variable.

The program is written in Python and it is well commented.

6 0
3 years ago
Computer A has an overall CPI of 1.3 and can be run at a clock rate of 600 MHz. Computer B has a CPI of 2.5 and can be run at a
kirill115 [55]

Answer:

Check the explanation

Explanation:

CPI means Clock cycle per Instruction

given Clock rate 600 MHz then clock time is Cー 1.67nSec clockrate 600M

Execution time is given by following Formula.

Execution Time(CPU time) = CPI*Instruction Count * clock time = \frac{CPI*Instruction Count}{ClockRate}

a)

for system A CPU time is 1.3 * 100, 000 600 106

= 216.67 micro sec.

b)

for system B CPU time is =\frac{2.5*100,000}{750*10^6}

= 333.33 micro sec

c) Since the system B is slower than system A, So the system A executes the given program in less time

Hence take CPU execution time of system B as CPU time of System A.

therefore

216.67 micro = =\frac{2.5*Instruction}{750*10^6}

Instructions = 216.67*750/2.5

= 65001

hence 65001 instruction are needed for executing program By system B. to complete the program as fast as system A

3 0
3 years ago
Windows workstations all have elements of server software built-in. What are these elements, and why is the Windows Professional
lions [1.4K]

Answer:

The answer is below

Explanation:

Elements of Server software that is built-in, in Windows workstations are:

1. Hard drives,

2. RAM (Random Access Memory)

3. Processors

4. Network adapters.

Windows Professional OS is not considered a server due to the following:

1. Windows Professional OS has a limit on the number of client connections it allowed.

2. Unlike Server, Professional OS uses less memory

2. In comparison to Server, Professional OS uses the CPU less efficiently

4. Professional OS is not built to process background tasks, unlike Server that is configured to perform background tasks.

6 0
3 years ago
Dashed lines that display on your slide when you are moving an object and that assist you with alignment are referred to as:
Umnica [9.8K]
Smart guides is the answer.
7 0
2 years ago
Read 2 more answers
A server is a special kind of computer that manages access to resources such as files, applications, peripherals, emails, and we
Basile [38]

Answer:

true

Explanation:

6 0
2 years ago
Read 2 more answers
Other questions:
  • The git _____ command will display the last commit and what were the changes you made.
    9·1 answer
  • It is better to know the main components of all computer programming languages
    9·1 answer
  • Write a function that iteratively appends random 1's and 0's to an array to form a binary number. The function returns the binar
    13·1 answer
  • What command would you use to list the text files in your
    7·1 answer
  • Bitnet, one of the predecessors of the internet was launched in 1981. what does bitnet stand for?
    12·1 answer
  • How many responses does a computer expect to receive when it broadcasts an ARP request?why?
    12·1 answer
  • Why was the tesla model s help change the was we see EV
    12·1 answer
  • Write a Python function that takes as input a list, A, and returns two lists L and G. L constains all numbers in A, which are no
    13·1 answer
  • Brenda has created a Microsoft Excel spreadsheet which has 1000's of cells of data. She is looking for specific information in t
    11·1 answer
  • What does ATM mean on lego mario mean I know that this is not school related but I trying to help my brother ​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!