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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:18:40+00:00 2026-06-09T12:18:40+00:00

static void just_traverse(sll **head_ref) { sll *first = *head_ref; sll *second = (*head_ref)->next; if(second

  • 0
static void just_traverse(sll **head_ref) {
    sll *first = *head_ref;
    sll *second = (*head_ref)->next;

    if(second == NULL) {
            return;
    }

    just_traverse(&(second));
    *head_ref = second;
    printf("%d \t",second->payload);
}

In above code if I remove *head_ref = second; I get output with respect to stack however If I put this line *head_ref = second; It always print last element say {4,3,2,1} then it always prints 1?Can anybody explain why?

  • 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-09T12:18:41+00:00Added an answer on June 9, 2026 at 12:18 pm

    If Your list contains {4,3,2,1}, then your output should be 1 1 1 right.

    This because of the statement *head_ref = second;. In the 3rd call to the function just_traverse head_ref will points to 2 and second will points to 1. Now you are updating **head_ref to 1. Now you are printing second. So output will be value 1

    And then it will return to the 2nd call, here head_ref is 3 and second is 1 (not 2 becuase we updated in 3rd all). Now againg assigning 1 to head and printing second. Again it will print the value 1 only.

    And then it will return to the 1st call, here head_ref is 4 and second is 1 (not 3 because we updated in 2nd call). Now againg assigning 1 to head and printing second. Again it will print the value 1 only.

    So the output will be three 1

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

Sidebar

Related Questions

static void Main() { string str; str = Console.ReadLine(); while (str != null)//HERE! {
Code static void MyClass::ThreadEntryStatic() { //... } void MyClass::Begin() { CreateThread(..,ThreadEntryStatic,..); } In which
I have just encountered this following code: public class TestFinally { public static void
I just saw code similar to this: public class Scratch { public static void
I'm new to Java and just code a program with BigInteger. public static void
Here's the code: static void Main(string[] args) { Semaphore loadFinished = new Semaphore(0, 1);
Consider the following code public static void method(String[] srgs){ try{ }catch(){ System.out.println(Hello World +
Consider this code snippet: class Program { static void Main(string[] args) { Console.WriteLine(Test().ToString()); }
I have the following code: public static void Invoke(string assemblyName, string scheduledTaskExecutorName) { ObjectHandle
The following code gives an unreachable statement compiler error public static void main(String[] args)

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.