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 6060163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:47:40+00:00 2026-05-23T08:47:40+00:00

I was going through some practice coding problems , and i came across one

  • 0

I was going through some practice coding problems , and i came across one –

Implement an algorithm to delete a node in the middle of a single linked list,
given only access to that node.

EXAMPLE:
Input: the node ‘c’ from the linked list a->b->c->d->e
Result: nothing is returned, but the new linked list looks like a->b->d->e

The solution to this is to simply copy the data from the next node into this node and then
delete the next node.

The above solution is keeping java in mind, as the programming language.
I am wondering what would happen to the content of deleted node? Will its fate be different in java and c++?
And also, i think the perfect answer to this question should also deallocate the memory of the deleted node. How do we do that in c++?

  • 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-23T08:47:40+00:00Added an answer on May 23, 2026 at 8:47 am

    In Java, the memory could eventually be freed by the garbage collector. There is no guarantee of when (and therefore, if) that happens. (In practice, it will usually happen very quickly).

    In C++ with smart pointers, the deallocation of memory is guaranteed as soon as the object cannot be addressed anymore. In effect, it works pretty much like garbage collection in Java as long as you don’t have any circular reference graphs.

    If you are not using smart pointers, you’ll have to manually call delete c (or free(c)). If you don’t do this, your program will have allocated memory it can never use again.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was going through some code and came across a scenario where my combobox
I'm going through some practice problems, and I saw this code: #include <stdio.h> #include
I was just going through some codes of C++. Where in I came across
I'm going through some old stored procedures at work and constantly come across CASE
We are currently going through the long process of writing some coding standards for
After going through the Appendix A, C# Coding Style Conventions of the great book
I'm going through the problems on projecteuler.net to learn how to program in Erlang,
I'm going through some examples for how to configure asynchronous JMS messaging with Spring,
So I'm (still) going through some slow legacy sql views used to do calculate
I'm thinking about starting a new project using EF 4 and going through some

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.