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
SOVA2 [1]
3 years ago
8

Write a program that creates a linked list object of 10 characters and creates a second list object containing a copy of the fir

st list, but in reverse order.
Computers and Technology
1 answer:
slamgirl [31]3 years ago
4 0

Answer:

Below code is in c++ with explanation.

Explanation:

Explanation is in comment format, any line starting with //.

#include <iostream>

#include <cstdlib>

using namespace std;

//creating a Node struct which holds node data

struct Node {  

  char data;  

  struct Node *next;  

};  

//creating variable of Node as head

// this head is the start point of ordered Linked list

struct Node* head = NULL;    

// This method is used to insert new value in node

void insert(char new_data) {  

// allocating the memory for new node

  struct Node* new_node = (struct Node*) malloc(sizeof(struct Node));  

// assigning the data to new node

  new_node->data = new_data;  

// If head == null then it means we are inserting first value

// it will return after creating first node and assign it to

// head as head is the entry point

  if(head == NULL){

    new_node->next=NULL;

   head=new_node;

    return;

  }

// Now we need to treverse to end of linked list

// that's why creating a lastNode variable  

// As we don't want our head to point any other node

// except first node

  Node* lastNode = head;

  while(lastNode->next != NULL){

   lastNode=lastNode->next;

  }

// as last node next will be null to end the traversing  

// on linked list

  new_node->next= NULL;

// assigning last node to its previous node  

  lastNode->next = new_node;  

   

}  

// This variable will hold the first node for reverse linklist

struct Node* reverseHead = NULL;    

// This method will reverse the ordered linklist

void reversLinkList(){

  Node* lastNode = head;

// traversing the ordered linklist

  while(lastNode!= NULL){

// creating new linked list

   struct Node* new_node = (struct Node*) malloc(sizeof(struct Node));  

   new_node->data = lastNode->data;  

   new_node->next = reverseHead;  

   reverseHead = new_node;  

   lastNode = lastNode->next;

  }

   

}

// display method will travers the linklist that

// was passed throw paramter

void display(Node* node) {  

  struct Node* ptr;

  ptr = node;

  while (ptr != NULL) {  

     cout<< ptr->data <<" ";  

     ptr = ptr->next;  

  }  

}  

// main method is the entry point of this program

int main() {  

// adding 10 nodes by calling insert method

  insert('a');

  insert('b');

  insert('c');

  insert('d');

  insert('e');

  insert('f');

  insert('g');

  insert('h');

  insert('i');

  insert('j');

  cout<<"The Ordered linked list is: ";

// calling display method with head to print ordered linklist

  display(head);  

  cout<<endl;

  cout<<"The Reversed linked list is: ";

// calling reversLinkList to reverse the ordered linklist

  reversLinkList();

// calling display method with reverseHead to display  

// reversed linklist

  display(reverseHead);

   

  return 0;  

}

You might be interested in
What does the following code output? System.out.println((5+20 + 5)<br> * (10 / 10))
shepuryov [24]

Explanation:

the output of your code is 30

8 0
3 years ago
What type of socket should be used with an air impact wrench
Vikentia [17]
<span>Black sockets should be used, but the color is not the reason why. Chrome sockets will cause splits to form in the socket walls pretty quickly, after only a few uses. But the black sockets are that color because they have gone through a process called Parkerizing that coats the surface of the socket in order to provide more resistance when being used and protect the socket against corrosion.</span>
3 0
2 years ago
Collaborative filtering is
vazorg [7]

Answer:

A: used by ISP's to filter out email SPAM

C: a way to help an individual focus on best choices when deciding what to watch or buy.

Explanation:

Collaborative filtering uses a community-based approach to filter spam. It works by collecting numerous email users from around the world. By doing this, it becomes possible for users to flag emails that are spam and those that are legitimate.

Also Collaborative Filtering is one of the most efficient techniques for building a system that can help a user when it comes to recommending best choices based on information from a large number of users.

4 0
3 years ago
When Kristy recently started a photography business, she downloaded Photoshop to her computer to edit her photos. She notices he
Evgesh-ka [11]

Answer: A. System window and C. System Information window

Explanation:

Hi, RAM stands for Random Access Memory. RAM stores information about running programs in your computer, as long the computer is on.

To know how much RAM is installed on a system you can use the system window tool.

In windows 10 Right click on "Start Menu" and click on "System" in pop-up menu to open "System" window.

System window will show basic information of the computer, including the amount of RAM installed.

Also you can Type "System Information" in the search box, and select "System Information" from search results.

"System Information" window shows a more detailed system summary, of hardware resources and devices. Incluiding RAM.

Feel free to ask for more if needed or if you did not understand something.

7 0
3 years ago
What is your understanding about the subject “digital image processing”?
N76 [4]

Answer:

Here's your answer mate.....☺️☺️

Explanation:

In computer science, digital image processing is the use of a digital computer to process digital images through an algorithm. ... It allows a much wider range of algorithms to be applied to the input data and can avoid problems such as the build-up of noise and distortion during processing.

<em><u>Hope it helps </u></em>☺️

5 0
3 years ago
Other questions:
  • Use the script below as a starting point to create a Rectangle class. Your rectangle class must have the following methods;A con
    12·1 answer
  • Write a program that reads in the length and the width of a rectangular yard.
    5·1 answer
  • Malware that corrupts the target operating system in such a manner that a network defender can no longer trust the native OS is
    15·1 answer
  • Discuss whether the redundant data should be addressed prior to beginning the wireless network architecture project, in coordina
    11·1 answer
  • The physical part or components of a computer system called​
    5·2 answers
  • In what other game can kids line up in a row
    6·1 answer
  • Match the elements of a web page with their descriptions.
    12·1 answer
  • The difference between page break and section brek​
    5·2 answers
  • In ip address 202.54.15.178, 15.178 is ______ address.
    8·1 answer
  • Why is computer called information processing machine ?????​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!