Data Structures and Algorithms

2007-03-20 7:51 pm
Design an algorithm to return the index in A at which v is found. If v is
Not found in A, return -1. (A simple and straight forward solution is to scan the array elements one-by-one, until v is found or all elements have been examined.)The array index starts with 0 and ends at n-1. Specify the algorithm as a pseudo-code.

回答 (1)

2007-03-20 8:00 pm
✔ 最佳答案
found=-1
For index from 0 to n-1
if A(index)="v" then
found=index
exit loop
end if
loop
參考: me


收錄日期: 2021-04-23 16:47:09
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070320000051KK00930

檢視 Wayback Machine 備份