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

  • SEARCH
  • Home
  • 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 8919007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T05:54:16+00:00 2026-06-15T05:54:16+00:00

I have a project for computer science class and have everything done except for

  • 0

I have a project for computer science class and have everything done except for one method. The delete method. Basically I am making a linked list from user input and I need to be able to delete all nodes (which is done) and delete a single specified node. So I need to search through the list of nodes find the one to delete and delete it. Anything that can help is appreciated. If you have a solution please offer an explanation as I am trying to learn and just solve the problem.

I’m not going to give you the GUI because I don’t think it is necessary but here is the node class.

public class MagazineList {
private MagazineNode list;

    public MagazineList(){
        list = null;
    }


public void add(Magazine mag){
    MagazineNode node = new MagazineNode(mag);
    MagazineNode current;

    if(list == null) {
        list = node;
    }
    else {
        current = list;
        while(current.next != null)
            current = current.next;
        current.next = node;
    }   
}
public void insert(Magazine mag) {
  MagazineNode node = new MagazineNode (mag);

  // make the new first node point to the current root
  node.next=list;

  // update the root to the new first node
  list=node;
}

public void deleteAll() {
    if(list == null) {

    }

    else {
        list = null;
    }
}
public void delete(Magazine mag) {
    //Delete Method Goes Here
}

public String toString(){
    String result = " ";

    MagazineNode current = list;
    while (current != null){
        result += current.magazine + "\n";
        current = current.next;     
    }
    return result;
}
private class MagazineNode {
    public Magazine magazine;
    public MagazineNode next;


    public MagazineNode(Magazine mag){
        magazine = mag;
        next = null;
    }
}
}

UPDATE

Here is the method I put together and it goes through the first part into the while loop and never recognizes the same item in the list. I used the exact same thing for the input and delete methods yet it will not recognize it. Any help is appreciated.

public void delete (Magazine mag) {
MagazineNode current = list;
MagazineNode before;

before = current;

if(current.equals(mag)){
    before.next = current;
    System.out.println("Hello");
}

while ((current = current.next)!= null){
    before = current.next;
    System.out.println("Hello Red");

    if(current.equals(mag)){
        current = before;
        System.out.println("Hello Blue");
    }
}
 }
  • 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-06-15T05:54:17+00:00Added an answer on June 15, 2026 at 5:54 am

    Without spoon feeding you the answer. deletion is a bit like removing one link of a chain – you cut out the link and join up the two (new) ends.

    So, deleting “B” would mean changing

    A --> B --> C --> D
    

    to this

    A --> C --> D
    

    In pseudo code, the algorithm would be:

    • start the algorithm with the first node
    • check if it is the one you want to delete
    • if not, go to the next node and check again (go back to the previous step)
    • if so, make the next node of the previous node the next node of this node
    • remove the reference from this node to the next node
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a project for my computer science class that basically uses an
I have to do a project for my Computer Science class. The problem is:
I am college student (computer science) and have just started a C# programming class.
I'm a Computer Science student and have to complete my final year project. I
I have a project on one computer that I need to work on another
I just got a project in my Computer Science class. We got the assignment
I have a project hosted on GitHub. I created a branch on one computer,
In computer science I have learned that .jar files are basically a compressed set
I am currently working on a computer science project where I have to evaluate
I wonder how many of you have implemented one of computer science's classical algorithms

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.