Create a doubly linked list

Assignment Help Data Structure & Algorithms
Reference no: EM132276377

Question: 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 <cstdlib> //Random Function cstdlib

#include <iostream> //I/O Stream iostream

#include <ctime> //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<unsigned int>(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<<temp->data<<endl;

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 */

Reference no: EM132276377

Questions Cloud

Compare the role and function of the federal court system : The structures of these court systems are very similar in that they are broken up into multiple levels to handle both criminal and civil matters.
Impact of various personality types within the workplace : Impact of various personality types within the workplace - determine leadership qualities and best placement in an organization
Essay on philosophy of leadership and application : Organisational Behaviour and Leadership - Assessment – Individual essay - Demonstrate a critical understanding of organisational behaviour
What decisions did the fbi and saic make : What decisions did the FBI and SAIC make during development that increased risk? How can these be avoided in the next project that the FBI takes on?
Create a doubly linked list : From your Singular Linked List. Create a Doubly Linked List. Use this to create a prioritized list by use. Bring to front those links recently queried.
Discussion of key elements of the model of stewardship : Review the models of stewardship presented by Wilson (2016) and Block (1993) - analyse the potential benefits and challenges that might occur upon employing
Write your implementation in a module you will name : Define, directly in the interactive shell, function perimeter() that takes, as input, the radius of a circle (a nonnegative number) and returns the perimeter.
What do you see as the benefits of such an effort : Discuss why a company would want to go through the expense and effort to develop a Data Warehouse environment. What do you see as the benefits.
Disucss the term managing information systems : This capstone course will require a BEST PRACTICES PRESENTATION which will consist of a PowerPoint presentation. The project presentation will be a detailed.

Reviews

Write a Review

Data Structure & Algorithms Questions & Answers

  Write at least a one-page critic of the cisc approach

write at least a one-page critic of the CISC approach showing its disadvantages while showing the advantages of the RISC approach. You may want to use real-life example machine performance as a support for your support of the RISC philosophy.

  Explain the situation where your example is utilized

Share & Explain the situation where your example is utilized. Discuss why a priority queue benefits the users in this situation.

  Define degree-constrained spanning tree of a simple graph

Show that if every circuit not passing through any vertex other than its initial vertex more than once in a connected graph contains an odd number of edges.

  Design an algorithm for finding the number

Design an O(n)-time algorithm for finding that number. You are only allowed to use O(1) additional space besides the array A itself.

  Tic tac toe game - design a gui and implement tic tac toe

tic tac toe game - design a gui and implement tic tac toe game in java-implement a random move using two methods

  Discuss why it is necessary to balance binary search trees

Discuss why it is necessary to balance Binary Search Trees (BSTs). Calculate the Average Comparison Effort (ACE) value of the BST.

  Creating java program using two arrays

Create a program in Java which defines 2-unconstrained arrays of user defined length n, that contain n Random numbers each and which outputs addition of pairs of elements.

  Algorithm using java programming language

Design a dynamic programming algorithm to find the value of the optimal plan. Implement your algorithm using JAVA programming language.

  Data structures class

data structures class this project will give you an introduction. There are two important data structures that you will learn and use. The first is a stack, it is a LIFO (Last In First Out) structure. You can think of it like a a stack of plates in y..

  Discuss fault tolerance approaches that systems managers use

Discuss fault tolerance approaches that systems managers use to assure continuity of operations

  Determine the number of peaks and valleys in given terrain

Problem: Navigation over a terrain can be an important concept. Usually you want to avoid high areas (peaks) and low areas (valleys) -

  Create algorithm which generates access control matrix

Create an algorithm which generates the access control matrix A for any given history matrix H of the Chinese Wall model.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd