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...
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.
In C++, write a member method delete() that deletes a node from a linked list at...
In C++, write a member method delete() that deletes a node from a linked list at a random position. (It should first randomly generate that position. and then delete that node).
Write a PHP Program to display all the $_SERVER elements
Write a PHP Program to display all the $_SERVER elements
Create a C program that solves the word search puzzle contained in the file 'WordSearchPuzzle.txt'. The...
Create a C program that solves the word search puzzle contained in the file 'WordSearchPuzzle.txt'. The words that need to be found are in the file 'WordList.txt'. There are 100 words to be found. You must find the location of the first and last letter of each word as well as the cardinal direction that describes the word's orientation. The location of first and last letters are to be described in terms of row and column, with indexing starting at...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT