Question

In: Computer Science

This is c++ Create a program where you create, display, search, delete elements within a linked...

This is c++

Create a program where you create, display, search, delete elements within a linked list.

Watch your function arguments. Pointer parameters are passed by reference to some functions and by value to others.

Functions to make:

copy : copies element in linked list

destroy all: destroys all elements in linked list

wherethisgoes:user  enters element and returns where the element is located

insert sorted: inserts element

create using linked lists with a head pointer and so forth

Solutions

Expert Solution

LINKED LIST:

IT IS A LINEAR DATA STRUCTURE WHERE EACH ELEMENT IS CONSIDER AS A SINGLE OBJECT.IT IS NOT STORED IN CONTAGIOUS LOCATION.HERE THE ELELMENTS ARE LINKED USING POINTERS.EACH NODE OF LIST IS MADE WITH TWO ITEMS:-THE DATA AND THE REFERENCE TO THE NEXT NODE.THE LAST NODE HAS A REFERENCE TO NULL.

C++ PROGRAM:

#include<iostream.h>

struct Node

{

int d;

struct Node *next;

};

struct Node *head=NULL;

void insert sorted(int new_d)

{

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

new node->d=new_d;

new node->next=head;

head=new_node;

}

void display()

{

struct Node *ptr;

ptr=head;

while(ptr!=NULL)

{cout<<ptr->d<<" ";

ptr=ptr->next;

}

}

void deletelist()

{

struct Node*current=*head;

Node*next;

while(current!=NULL)

{next=current->next;

free(current);

current=next;

}

*head=NULL;

}

void copy()

{

struct Node*arbit=*head;

Node *next;

copy_node->arbit=copy_node->arbit->next;

copy_node=copy_node->next;

}

insert sorted main()

{insert sorted(1);

insert sorted(2);

insert sorted(8);

insert sorted(3);

insert sorted(10);

cout<<"THE LINKED LIST IS :";

display();

cout<<"deleting linked list:";

deletelist();

cout<<"linked list deleted;

copy();

cout<<"copied ;ist is";

}

}

  

  


Related Solutions

Using C++, you will create a program, where you will create two doubly linked lists. These...
Using C++, you will create a program, where you will create two doubly linked lists. These doubly linked lists will contain integers within them. Using the numbers in both of these linked lists, you add the numbers together, and insert the addition of the two numbers into a singly linked list. the input can be from the user or you just write the input. for example, if one number in the doubly linked list is 817 and in the other...
I need a MIPS Assembly program that "Display the elements of the linked list in reverse...
I need a MIPS Assembly program that "Display the elements of the linked list in reverse order." It needs subprogram and those subprogram does not have t registers.
How would I create a program in C++ where you build and maintain two binary search...
How would I create a program in C++ where you build and maintain two binary search trees of information? I have already created the file reader which I will list on the end. The 2 binary search trees should be controlled by the Operations: L -- for launching a satellite, which will save it's info to the first set or D -- for deorbit the satellite. The other operations I'm looking to implement are: F -- for find, where user...
/* *fix the below C Program to Display the Nodes of a Linked List in Reverse...
/* *fix the below C Program to Display the Nodes of a Linked List in Reverse */ #include <stdio.h> #include <stdlib.h> struct node { int visited; int a; struct node *next; }; int main() { struct node *head = NULL; generate(head); printf("\nPrinting the list in linear order\n"); linear(head); printf("\nPrinting the list in reverse order\n"); display(head); delete(head); return 0; } void display(struct node *head) { struct node *temp = head, *prev = head; while (temp->visited == 0) { while (temp->next !=...
Part 2- - Create and display a singly Linked List with 5 elements (see below)                 Node*...
Part 2- - Create and display a singly Linked List with 5 elements (see below)                 Node* head                  Node*second                  Node*third                 Node*forth                  Node*fifth 2-Assign the data 5, 6, 8, 10, 12 to each node 3-Display the output GIVEN CODE: #include <studio.h> struct Array { int A[10]; int size; int length; }; void Display(struct Array arr) {      int i; printf("\nElements are\n");      for(i=0;ilengthsize) arr->A[arr->length++]=x; } void Insert(struct Array *arr,int index,int x) {      int i;          if(index>=0 && index <=arr->length) {      for(i=arr->length;i>index;i--)      arr->A[i]=arr->A[i-1]; arr->A[index]=x; arr->length++; }...
Write a program where you- 1. Create a class to implement "Double Linked List" of integers....
Write a program where you- 1. Create a class to implement "Double Linked List" of integers. (10) 2. Create the list and print the list in forward and reverse directions. (10)
JAVA PROGRAM Create a Binary Search Tree with the following elements in the order mentioned below:...
JAVA PROGRAM Create a Binary Search Tree with the following elements in the order mentioned below: 5, 85, 89, 3, 2, 8, 65, 92 Print the Pre-order of this tree Print the height and the balance factor of the nodes in the order they were inserted (5, 85, 89, 3, 2, 8, 65, 92) in the form of a table with three columns and 9 rows. Use column headers “Node”, “Height”, and “Balance Factor” for the three columns respectively. Use...
Write a C program that can search for a string within a text file, replace it...
Write a C program that can search for a string within a text file, replace it with another string and put results in a new file.
C++ Instantiate a binary search tree object and create such tree using elements of the sequence...
C++ Instantiate a binary search tree object and create such tree using elements of the sequence 8,3,10, 1,6,9, 14, 4,7, 13 with 8 as root of the tree. Find maximum and minimum elements of the tree, successor(10) and predecessor(13), print the inorder, postorder and preorder traversal of the tree.
Create a C++ integer linked list program that performs the following methods below: Please create these...
Create a C++ integer linked list program that performs the following methods below: Please create these three source files: intList.h, intList.cpp, & intListTest.cpp. Implement recursive routines in the intList class to do the following: Print the list in reverse order Return the value in the middle node Return the average of all the odd values Remove every node containing an odd value Modify main (in IntListTest.cpp) so it does the following: Insert the numbers 1, 3, 4, 6, 7, 10,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT