Follow

Translate

Tuesday, March 8, 2016

Algorithm Largest Element in Array

Algorithm 2.1: (Largest Element in Array) A nonempty array DATA with N numerical values is given.This algorithm finds the location LOC and the value MAX of the largest element of DATA.The variable K is used as a counter.

Step 1.  [Initialize] Set K: = 1, LOC: = 1 and MAX : = DATA[1].

Step 2.  [Increment Counter]. Set K : = K+1.

Step 3. [test counter.] If K > N, then:
Write: LOC,  MAX, and Exit.

Step 4. [Compare and Update.] If MAX < DATA[K], then:
Set LOC: = K and MAX : = DATA[K].

Step 5. [Repeat Loop.] Go to the Step 2.

If You want to learn about the technology, computer science & engineering, web programming, freelancing, earning please click here :CSE SOLVE

Related Posts:

  • Inserting at the Beginning of a List Algorithm:   INSFIRST(INFO,  LINK,  START, AVAIL, ITEM) This algorithm inserts ITEM as the first node in the list. 1.     [OVERFLOW?]  If AVAIL = NULL , then : Write: OVERFLOW… Read More
  • Inserting at the Beginning of a List Algorithm:   INSFIRST(INFO,  LINK,  START, AVAIL, ITEM) This algorithm inserts ITEM as the first node in the list. 1.     [OVERFLOW?]  If AVAIL = NULL , then : Write: OVERFLOW… Read More
  • Deleting the Node with a Given ITEM of Information Procedure:   DELETE(INFO, LINK, START, AVAIL, ITEM) This algorithm deletes from a linked list the first node N which contains given ITEM of information. 1.  [Use procedure FINDB to find the location o… Read More
  • Deleting the Node Following a Given Node Algorithm: DEL(INFO,  LINK,  START,  AVAIL,  LOC,  LOCP) This algorithm deletes the node N with location LOC,  LOCP is the location of the node which precedes N or , where N is the first node… Read More
  • Deleting the Node Following a Given Node Algorithm: DEL(INFO,  LINK,  START,  AVAIL,  LOC,  LOCP) This algorithm deletes the node N with location LOC,  LOCP is the location of the node which precedes N or , where N is the first node… Read More

0 comments:

Post a Comment