SlideShare a Scribd company logo
1 of 5
A) From your Singular Linked List,
Create a Doubly Linked List.
Use this to create a Sorted Linked List,
Use this to create a prioritized list by use. Bring to front those
links recently queried.
Code c++
main.cpp
//System Libraries
#include //Random Function cstdlib
#include //I/O Stream iostream
#include //Time Function setting random seed ctime
using namespace std;
//User Libraries
#include "Node.h"
//Global Constants
//Physics/Math/Conversions/2+ArrayDimenstions
//No Global Variables
//Function Prototypes Here
Node *filNode(int);
void prtNode(Node *);
void destroy(Node *);
//Execution Begins with Main
int main(int argc, char** argv) {
//Random Number seed set once here
srand(static_cast(time(0)));
//Declare and initialize variables
Node *head=filNode(10);
//Display results here
prtNode(head);
//Clean up code
destroy(head);
//Exit stage right
return 0;
}
Node *filNode(int n){
//Initialize the front
Node *head=new Node;
head->data=n--;
head->ptr=NULL;
Node *tail=head;
//Loop until filled
do{
Node *next=new Node;
next->data=n--;
next->ptr=NULL;
tail->ptr=next;
tail=next;
}while(n>=0);
return head;
}
void prtNode(Node *head){
Node *temp=head;
do{
cout<data<
temp=temp->ptr;
}while(temp!=NULL);
}
void destroy(Node *head){
Node *temp=head;
do{
temp=temp->ptr;
delete head;
head=temp;
}while(temp!=NULL);
}
Node.h
#ifndef NODE_H
#define NODE_H
struct Node{
int data;
Node *ptr;
};
#endif /* NODE_H */

More Related Content

More from vickeryr87

Define civilization. Do we really need it in order to survive and pr.docx
Define civilization. Do we really need it in order to survive and pr.docxDefine civilization. Do we really need it in order to survive and pr.docx
Define civilization. Do we really need it in order to survive and pr.docx
vickeryr87
 
Define and describe Active Listening.Describe how it is used in th.docx
Define and describe Active Listening.Describe how it is used in th.docxDefine and describe Active Listening.Describe how it is used in th.docx
Define and describe Active Listening.Describe how it is used in th.docx
vickeryr87
 

More from vickeryr87 (20)

Define communication in your own words. Identify and distinguish amo.docx
Define communication in your own words. Identify and distinguish amo.docxDefine communication in your own words. Identify and distinguish amo.docx
Define communication in your own words. Identify and distinguish amo.docx
 
Define Civil Liberties. List 5 Civil Liberties. How do they differ.docx
Define Civil Liberties. List 5 Civil Liberties. How do they differ.docxDefine Civil Liberties. List 5 Civil Liberties. How do they differ.docx
Define Civil Liberties. List 5 Civil Liberties. How do they differ.docx
 
Define civilization. Do we really need it in order to survive and pr.docx
Define civilization. Do we really need it in order to survive and pr.docxDefine civilization. Do we really need it in order to survive and pr.docx
Define civilization. Do we really need it in order to survive and pr.docx
 
Define case management and care management and compare the dif.docx
Define case management and care management and compare the dif.docxDefine case management and care management and compare the dif.docx
Define case management and care management and compare the dif.docx
 
Define Bureaucracy.  Government at all levels has grown enormously, .docx
Define Bureaucracy.  Government at all levels has grown enormously, .docxDefine Bureaucracy.  Government at all levels has grown enormously, .docx
Define Bureaucracy.  Government at all levels has grown enormously, .docx
 
Define and explain how the Twitter search function works to search f.docx
Define and explain how the Twitter search function works to search f.docxDefine and explain how the Twitter search function works to search f.docx
Define and explain how the Twitter search function works to search f.docx
 
Define and relate these different terminologies and Information Gove.docx
Define and relate these different terminologies and Information Gove.docxDefine and relate these different terminologies and Information Gove.docx
Define and relate these different terminologies and Information Gove.docx
 
Define and provide examples of-Basic probability- Bayes the.docx
Define and provide examples of-Basic probability- Bayes the.docxDefine and provide examples of-Basic probability- Bayes the.docx
Define and provide examples of-Basic probability- Bayes the.docx
 
Define and discuss the phrase Manifest Destiny. Explain how this b.docx
Define and discuss the phrase Manifest Destiny. Explain how this b.docxDefine and discuss the phrase Manifest Destiny. Explain how this b.docx
Define and discuss the phrase Manifest Destiny. Explain how this b.docx
 
Define and discuss the differences between vision and mission stat.docx
Define and discuss the differences between vision and mission stat.docxDefine and discuss the differences between vision and mission stat.docx
Define and discuss the differences between vision and mission stat.docx
 
Define and discuss the four types of innovation. How might these.docx
Define and discuss the four types of innovation. How might these.docxDefine and discuss the four types of innovation. How might these.docx
Define and discuss the four types of innovation. How might these.docx
 
Define and discuss the data wiping process.Discuss how a cloud.docx
Define and discuss the data wiping process.Discuss how a cloud.docxDefine and discuss the data wiping process.Discuss how a cloud.docx
Define and discuss the data wiping process.Discuss how a cloud.docx
 
define and discuss a values-based leadership approach to organizatio.docx
define and discuss a values-based leadership approach to organizatio.docxdefine and discuss a values-based leadership approach to organizatio.docx
define and discuss a values-based leadership approach to organizatio.docx
 
Define and differentiate political parties and interest groups. Why .docx
Define and differentiate political parties and interest groups. Why .docxDefine and differentiate political parties and interest groups. Why .docx
Define and differentiate political parties and interest groups. Why .docx
 
Define and describe the mobile web.Describe the different .docx
Define and describe the mobile web.Describe the different .docxDefine and describe the mobile web.Describe the different .docx
Define and describe the mobile web.Describe the different .docx
 
Define and describe the mobile web. Describe the differen.docx
Define and describe the mobile web.    Describe the differen.docxDefine and describe the mobile web.    Describe the differen.docx
Define and describe the mobile web. Describe the differen.docx
 
Define and describe the major sections of a research report used.docx
Define and describe the major sections of a research report used.docxDefine and describe the major sections of a research report used.docx
Define and describe the major sections of a research report used.docx
 
Define and Describe the following methods of clusteringPa.docx
Define and Describe the following methods of clusteringPa.docxDefine and Describe the following methods of clusteringPa.docx
Define and Describe the following methods of clusteringPa.docx
 
Define and describe Active Listening.Describe how it is used in th.docx
Define and describe Active Listening.Describe how it is used in th.docxDefine and describe Active Listening.Describe how it is used in th.docx
Define and describe Active Listening.Describe how it is used in th.docx
 
Define and describe business continuity.Define and describ.docx
Define and describe business continuity.Define and describ.docxDefine and describe business continuity.Define and describ.docx
Define and describe business continuity.Define and describ.docx
 

A) From your Singular Linked List,Create a Doubly Linked Lis

  • 1. A) From your Singular Linked List, Create a Doubly Linked List. Use this to create a Sorted Linked List, Use this to create a prioritized list by use. Bring to front those links recently queried. Code c++ main.cpp //System Libraries #include //Random Function cstdlib #include //I/O Stream iostream #include //Time Function setting random seed ctime using namespace std; //User Libraries #include "Node.h" //Global Constants //Physics/Math/Conversions/2+ArrayDimenstions //No Global Variables
  • 2. //Function Prototypes Here Node *filNode(int); void prtNode(Node *); void destroy(Node *); //Execution Begins with Main int main(int argc, char** argv) { //Random Number seed set once here srand(static_cast(time(0))); //Declare and initialize variables Node *head=filNode(10); //Display results here prtNode(head); //Clean up code destroy(head); //Exit stage right return 0;
  • 3. } Node *filNode(int n){ //Initialize the front Node *head=new Node; head->data=n--; head->ptr=NULL; Node *tail=head; //Loop until filled do{ Node *next=new Node; next->data=n--; next->ptr=NULL; tail->ptr=next; tail=next; }while(n>=0); return head; } void prtNode(Node *head){
  • 4. Node *temp=head; do{ cout<data< temp=temp->ptr; }while(temp!=NULL); } void destroy(Node *head){ Node *temp=head; do{ temp=temp->ptr; delete head; head=temp; }while(temp!=NULL); } Node.h #ifndef NODE_H #define NODE_H struct Node{