Skip to content

double linkedlist #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

smileybin
Copy link

@smileybin smileybin commented Jun 5, 2018

Submission Checklist

  • Your pull request targets the master branch of the repository.
  • You have only one commit (if not, squash them into one commit).
  • You have read the Contributing guidelines and your changes follow them.

Type of Change

  • Bug fix
  • New implementation

PR Description

Implement double linked list in c++
Functions: insert, delete, print

Issue #168


void Insert(T data)
{
Node<T> *newnode = new Node(data);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// set the newnode by dynamic allocation

{
Node<T> *newnode = new Node(data);

if (pHead == NULL)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if pHead == NULL, set the newnode as a pHead and pTail

return;
}
else {
Node<T> *walker = pHead;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// if not, set the pHead as a walker

}
else {
Node<T> *walker = pHead;
while (walker->pNext != NULL) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// walker's movement while walker->pNext != NULL


void Delete(T data)
{
if (pHead == NULL) return;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// if pHed == NULL, set the pHead as a walker

void Print()
{
if (pHead == NULL)return;
Node<T>* walker = pHead;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// set the pHead as a walker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants