How to resolve the algorithm Remove duplicate elements step by step in the PL/I programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Remove duplicate elements step by step in the PL/I programming language

Table of Contents

Problem Statement

Given an Array, derive a sequence of elements in which all duplicates are removed. There are basically three approaches seen here:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Remove duplicate elements step by step in the PL/I programming language

Source code in the pl/i programming language

*process mar(1,72);
remdup: Proc options(main);
   declare t(20) fixed initial (6, 6, 1, 5, 6, 2, 1, 7,
      5, 22, 4, 19, 1, 1, 6, 8, 9, 10, 11, 12);
   declare (i, j, k, n, e) fixed;

   put skip list ('Input:');
   put edit ((t(k) do k = 1 to hbound(t))) (skip,20(f(3)));
   n = hbound(t,1);
   i = 0;
outer:
   do k = 1 to n;
      e = t(k);
      do j = k-1 to 1 by -1;
          if e = t(j) then iterate outer;
      end;
      i = i + 1;
      t(i) = e;
   end;

   put skip list ('Unique elements are:');
   put edit ((t(k) do k = 1 to i)) (skip,20(f(3)));
end;

  

You may also check:How to resolve the algorithm Roots of unity step by step in the PL/I programming language
You may also check:How to resolve the algorithm Loops/Nested step by step in the PL/I programming language
You may also check:How to resolve the algorithm Non-decimal radices/Output step by step in the PL/I programming language
You may also check:How to resolve the algorithm Take notes on the command line step by step in the PL/I programming language
You may also check:How to resolve the algorithm Array length step by step in the PL/I programming language