Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1064525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T18:57:10+00:00 2026-05-16T18:57:10+00:00

How can I delete a node (between two nodes) from a single linked list

  • 0

How can I delete a node (between two nodes) from a single linked list without passing any parameters to the class function?

For example, I have a list of 6 nodes with one head node and I want to delete two of them (without prior knowledge of their address or position) from a class function, how would I do that?

void WordList::deleteNode(){
Node *temp;
temp=head;
if(temp->count<=10)
{
//delete this node... not sure how though
}
else
temp=temp->next;
}

where WordList is my class, Node is my struct which holds a word, a count, and a pointer.
I want to delete any node that has a counter of 10 or less.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T18:57:12+00:00Added an answer on May 16, 2026 at 6:57 pm

    Your edit has prior information, the bit that states “counter <= 10” 🙂

    Pseudo-code for deleting elements meeting that criteria in a singly-linked list:

    def delLessThanTen:
        # Delete heads meeting criteria, stop when list empty.
    
        while head != NULL and head->count <= 10:
            temp = head->next
            free head
            head = temp
        if head == NULL:
            return
    
        # Head exists, with count > 10, process starting there (we check
        #    NEXT element for criteria then delete if met).
    
        ptr = head
        while ptr->next != NULL:
            # If next in list meets criteria, delete it, otherwise advance.
    
            if ptr->next->count <= 10:
                temp = ptr->next->next
                free ptr->next
                ptr->next = temp
            else:
                ptr = ptr->next
    
        return
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My problem is deleting a node from linked list. I have two structs :
Delete every 't'th (t>1) node of a single linked list. In the resultant linked
How can I delete a node from a BST? I need an algorithm to
I trying to figure out how I can delete from multiple tables in SQL
From the documentation: If the platform supports the unsetenv() function, you can delete items
How can I delete the hidden cropped elements from a pdf from command line?
How can i delete a html-special char \ from a string. $string = 'This
how can I delete IE 8 cookies for a certain site from Python?
i have to switch in between two table as per users choice i can
I have a situation where I want to delete a random node from the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.