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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:42:46+00:00 2026-06-09T14:42:46+00:00

Having some problems with my given code. Thou it works accordingly, im required to

  • 0

Having some problems with my given code. Thou it works accordingly, im required to implement the “transverse” & “transverseR” functions.

Also i have trouble understanding what the given function pointers are for:
Function pointers => void (*visit)(link)

void traverse (link ls, void (*visit)(link)) {
  if (ls == NULL) {
    return;
  }
  (*visit) (ls);
  traverse (ls->next, visit);
  return;
}

void traverseR (link ls, void (*visit)(link)) {
  if (ls == NULL) {
    return;
  }
  traverseR (ls->next, visit);
  (*visit)(ls);
  return;
}


void square (link l) {
  // link tmp = NULL;
  int container = l->item;
  container = SQUARE(container);

  l->item = container;

}

void squareAll (link ls){

  link curr = ls;  
  while (curr != NULL){
    square(curr);
    curr = curr->next;
  }

  ls = curr;
}
  • 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-09T14:42:47+00:00Added an answer on June 9, 2026 at 2:42 pm

    These function pointers allows you to perform some custom actions using a function of your own on each list item as a list is being traversed. For example, you might write a function that decreases each node’s data:

    void decrease_item(link node)
    {
      --node->item;
    }
    

    The when you can call traverse(list_head, decrease_item) to decrease a value of every item in a list. You can create a function for printing each element’s item and so on.

    Btw, in your code above you can rewrite squareAll function in a more elegant manner:

    void squareAll (link ls){
       traverse(ls, square);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having some problems with a given test, that I'd like to debug
I'm a novice/beginner programmer having problems getting some simple client/server C code working. My
I am using paypal_adaptive gem and having some problems. This is my code in
I'm having some problems with my PHP server. Most of the functions when run
I've been having some strange problems with the collision code of a game I'm
I'm having problems with some sample code I got from Boulanger and Lazzarini's 'The
Currently having some problems- now = datetime.datetime.now() month = now.strftime(%B) site = wikipedia.getSite('en', 'wikiquote')
Im having some problems getting the Sticky Footer to work on my site. If
Im having some problems with a simple toggle in Safari. A really annoying flickering
I am having some problems with the PDF files that I make using 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.