PSUEDOCODE PATTERN ASSIGNMENT QUESTION

I HAVE THE FOLLOWING DOUBTS

  1. THE GIVEN QUESTION PATTERN IS CORRECT OR NOT I ATTACHED THE SNAP TELL ME WHICH ONE IS CORRECT
  2. FOR SUCH PATTERN BASED QUESTIONS WHAT IS THE IDEA BEHIND
  3. I ALWAYS STUCK IN SUCH QUESTIONS
  4. PLS TELL ME THE IDEA TO IMPROVE LOGIC BUILDING QUALTIES IN SUCH QUESTIONS

Second one is correct
triangle one

idea behind pattern question is to use loop correctly
first see the pattern and find what is inside it
try to break down the pattern into different components
as in this question
first we have some spaces
and then we have 2 types of nos
first are increasing then decreseasing

so we have 3 components

  1. spaces => ( n-i spaces) run a loop for that
  2. increasing numbers => from i to 2*i-1
  3. decreasing numbers => from 2*(i-1) to i decreasing nos

now try to write code first
and then as a reference you can use this code

WE NEED MAXIMUM SPACES IN FIRST LINE THEN SPACE DECREASES THEN WHY WE START ITS LOOP FROM 1 OR I WANT TO THE LOOP FOR SPACE START FROM MAXIMUM I GUESS AS WE HAVE ONLY 1 NUMBER IN FIRST LINE AND IF N=3 THEN N-1=2 SPACE IN FIRST LINE BUT IN THE GIVEN CODE IT STARTS FROM J=1 WHY SO PLS EXPLAIN

no of spaces are decrease
total no of spaces =n-i
as i increases n-i decrease so no of spaces decrease
let n=5
i=1 spaces=5-1=4
i=2 spaces=5-2=3
i=3 spaces=5-3=2
i=4 spaces=5-4=1
i=5 spaces=5-5=0

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.