Searching

# Searching - CIS3023: Programming Fundamentals for CIS...

This preview shows pages 1–5. Sign up to view the full content.

CIS3023: Programming Fundamentals for CIS Majors II Summer 2010 Ganesh Viswanathan Searchi ng Course Lecture Slides 28 May 2010 “ Some things Man was never meant to know. For everything else, there’s Google! ”

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Searching Querying for something •. Searching an array for a particular value is a common problem •. Example: Where is 100 in this array? 10 1 50 2 89 10 0 55 -20 75 -10 10 A[0 ] A[1 ] A[n- 1] n=1 0
Searching Querying for something •. Searching an array for a particular value is a common problem •. Example: Where is 100 in this array? 10 1 50 2 89 10 0 55 -20 75 -10 10 A[0 ] A[1 ] A[n- 1] n=1 0 Must return location in the array (index=4)

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
1. Let A be the array to be searched n - the number of elements k - the search target (or key) 2. Question: Does k occur in A? If k appears in A[0], A[1], …, A[n-1]: “found” determine its index i . that is, find i such that A[i] == k
This is the end of the preview. Sign up to access the rest of the document.

## Searching - CIS3023: Programming Fundamentals for CIS...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online