How to resolve the algorithm Doubly-linked list/Element insertion step by step in the BBC BASIC programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Doubly-linked list/Element insertion step by step in the BBC BASIC programming language

Table of Contents

Problem Statement

This is much like inserting into a Singly-Linked List, but with added assignments so that the backwards-pointing links remain correct.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Doubly-linked list/Element insertion step by step in the BBC BASIC programming language

Source code in the bbc programming language

      DIM node{pPrev%, pNext%, iData%}
      DIM a{} = node{}, b{} = node{}, c{} = node{}
      
      a.pNext% = b{}
      a.iData% = 123
      b.pPrev% = a{}
      b.iData% = 456
      c.iData% = 789
      
      PROCinsert(a{}, c{})
      END
      
      DEF PROCinsert(here{}, new{})
      LOCAL temp{} : DIM temp{} = node{}
      new.pNext% = here.pNext%
      new.pPrev% = here{}
      !(^temp{}+4) = new.pNext%
      temp.pPrev% = new{}
      here.pNext% = new{}
      ENDPROC


  

You may also check:How to resolve the algorithm Soundex step by step in the Prolog programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the bc programming language
You may also check:How to resolve the algorithm Playing cards step by step in the ALGOL 68 programming language
You may also check:How to resolve the algorithm Integer comparison step by step in the Phixmonti programming language
You may also check:How to resolve the algorithm Babbage problem step by step in the Lua programming language