Traversing, Inserting And Deleting linear Array in Data Structure in Hindi

Traversing, Inserting And Deleting linear Array in Data Structure in Hindi

 

Traversing in linear array

हमारे पास एक linear array LA है जिससे lower bound (LB) तथा upper bound (UB) है

एक operation PROCESS जो हर element मे visiting को दिखाता है ।

Algorithm:-

  1. [Initialize] set K=LB
  2. Repeat 3 & 4 while K=<=UB
  3. (Visiting element) PROCESS to LA [K]
  4. Set K=K+1

End if (end of step 2 loop)

  1. Exit

Inserting in linear array

INSERT (LA, K, N, ITEM)

यहाँ LA एक linear array है जिसमे N element है K वह position है जहां पर ITEM डालना है ।

Algorithm:-

  1. [Initialize] set J=N
  2. Repeat step 3&4 while J>=K
  3. Set LA [J+1]=LA[J]
  4. Set J=J-1(decrees counter)

(End of step 2 loop)

  1. (Insert element) set LA [K]= ITEM
  2. (reset) set N=N+1
  3. Exit

Deleting from in linear array

 DELETE (LA, N, K, ITEM)

यहाँ LA =linear array, N= numbers of element ओर K location है जहां से element delete करना है

Algorithm:-

  1. [Initialization] set ITEM=LA [K]
  2. Repeat for J=K to N-1
  3. Set LA[J]=LA[J+1] (j+1 element को upper bound मे  move करेगा )

End loop

  1. Exit

ये पोस्ट आपको केसी लगी क्र्पया अपनी राय कमेंट कर के बताए । 

[wpforms id=”197″ title=”true” description=”true”]

Leave a Comment