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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:40:52+00:00 2026-06-14T05:40:52+00:00

Possible Duplicate: context switch during doubly linked list creation I was reading The Design

  • 0

Possible Duplicate:
context switch during doubly linked list creation

I was reading The Design of the UNIX Operating System (Maurice Bach).

He gives the following example of a doubly linked-list.

struct queue{
    //pointers (back and forward)
    //other data
}*bp, *bp1

bp1->forp = bp->forp; //1

bp1->backp = bp; //makes sense
bp->forp = bp1; //makes sense

bp1->forp->backp = bp1; //2

I can’t understand the purpose of the statements marked 1 and 2. 1 seems wrong, 2 looks to be redundant.

Is this a valid way to create a doubly linked-list?

  • 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-14T05:40:53+00:00Added an answer on June 14, 2026 at 5:40 am

    The code is correct.

    bp is a doubly linked list.
    You want to insert bp1 into bp as the second item in the list (that is what the code does).

    To do that you need to set 4 pointers:

    bp1->forp should point to the second item in the list, bp->forp (//1 above)

    bp1->backp should point to the first item in the list, bp

    bp->forp should point to the inserted item, bp1

    The back pointer of the second item, bp1->forp->backp should point to the inserted item, bp1. (//2 above)

    Edit:

    Let’s call the structs A, B, C, D…
    The list (pointed to by bp consists of A, C, D… before the insert. We want to insert B (pointed to by bp1.
    <-> denotes the forward and backwards pointers.

    Before:

    bp --> A <-> C <-> D <-> E <-> ...
    bp1--> B
    

    After:

    bp--> A <-> B <-> C <-> D <-> E <-> ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: underscore.js _.each(list, iterator, [context]) what is context? So in the context of
Possible Duplicate: How can I convert a list<> to a multi-dimensional array? I want
Possible Duplicate: Difference between Activity Context and Application Context I want to know the
Possible Duplicate: non static method cannot be referenced from static context hey i have
Possible Duplicate: Context-sensitive grammar and Context-free grammar In my textbook, here is the explain
Possible Duplicate: Performance of jQuery selector with context In the jQuery DOCS it says
Possible Duplicate: how to add icon to context menu in c# windows form application
Possible Duplicate: BeanFactory vs ApplicationContext Simple word meaning of Application context and bean factory
Possible Duplicate: Django template can’t loop defaultdict I am wondering why my defaultdict(list) will
Possible Duplicate: Static Way to get Context on android? I have a broadcast receiver

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.