How to resolve the algorithm Doubly-linked list/Traversal step by step in the Ada programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Doubly-linked list/Traversal step by step in the Ada programming language

Table of Contents

Problem Statement

Traverse from the beginning of a doubly-linked list to the end, and from the end to the beginning.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Doubly-linked list/Traversal step by step in the Ada programming language

Source code in the ada programming language

with Ada.Containers.Doubly_Linked_Lists;
with Ada.Text_IO;

procedure Traversing is
   package Char_Lists is new Ada.Containers.Doubly_Linked_Lists (Character);

   procedure Print (Position : in Char_Lists.Cursor) is
   begin
      Ada.Text_IO.Put (Char_Lists.Element (Position));
   end Print;

   My_List : Char_Lists.List;
begin
   My_List.Append ('R');
   My_List.Append ('o');
   My_List.Append ('s');
   My_List.Append ('e');
   My_List.Append ('t');
   My_List.Append ('t');
   My_List.Append ('a');

   My_List.Iterate (Print'Access);
   Ada.Text_IO.New_Line;

   My_List.Reverse_Iterate (Print'Access);
   Ada.Text_IO.New_Line;
end Traversing;


  

You may also check:How to resolve the algorithm Program termination step by step in the PARI/GP programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the Kotlin programming language
You may also check:How to resolve the algorithm 9 billion names of God the integer step by step in the Clojure programming language
You may also check:How to resolve the algorithm Levenshtein distance step by step in the Icon and Unicon programming language
You may also check:How to resolve the algorithm Sum and product of an array step by step in the Zig programming language