Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

6. Write pseudocode for an algorithm that takes as input a list an of numbers, a

ID: 3417435 • Letter: 6

Question

6. Write pseudocode for an algorithm that takes as input a list an of numbers, and outputs "True if there are any two numbers in the list whose sum is equal to zero. (Note: The presence of a single 0 in the list does not suffice to ouput "True," but two 0s suffice to output "True.") Be sure to include all of the components described in Figure 2. Figure 6.1.1: Components in the description of an algorithm. A de scription of an algorithm usually includes A name for the algorithm A brief description the task performed by the algorithm A description of the input A description of the output A sequence of steps to follow Figure 2: Capture of Figure 6.1.1 from zyBooks Discrete Mathematics https://zybooks.zyante.com/#/ zybook/IIT230Spring2015/chapter/5/section/1.

Explanation / Answer

function checkSumZero() // Name of the function:- checkSumZero
   {
   array a[0...n-1] //An array of 'n' numbers that are to be scanned and checked, n must be integer and remaining elements can have any floating value
  
   c = 0 //A variable
   j = 0 //A variable
   checkZero = 0 //A variable
   whetherOutputTrue = false //A variable
  
       loop until c<=(n-1)
       {
           j=c+1
           loop until j<=(n-1)
           {
           checkZero=a[c] + a[j]
           if(checkZero equals 0)
               {
               Make whetherOutputTrue = true
               quit all loops
               }
           }
       }  
      
   if(whetherOutputTrue equals true)
       Output "True"
   else
       Output "False"
  
   }