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)
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.
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).
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...
Need to create a program in C++ that can display/write into a file called marks.txt. I'm...
Need to create a program in C++ that can display/write into a file called marks.txt. I'm not too worried about the functions, but I don't know how to store the different marks into a arrays. Any help would be appreaciated. Here's some details about the assignment. Student marks are kept in a text file as a single column. Each student may have a different number of assessments and therefore scores. The data recorded in the file for each student start...
C/ C++ Preferably 1. Write a simple program where you create an array of single byte...
C/ C++ Preferably 1. Write a simple program where you create an array of single byte characters. Make the array 100 bytes long. In C this would be an array of char. Use pointers and casting to put INTEGER (4 byte) and CHARACTER (1 byte) data into the array and pull it out. YES, an integer can be put into and retrieved from a character array. It's all binary under the hood. In some languages this is very easy (C/C++)...
how to do circular linked list in c++ (inset and delet and display)
how to do circular linked list in c++ (inset and delet and display)
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT