You are not logged in. Lock_open    

Browse tutorials by Tag - q

Linear Search of an Array (Eclipse) Time: 9:08 Gb
Average:
  • Currently 3.1/5 Stars from 50 ratings
  •  
  •  
  •  
  •  
  •  
50 ratings
Your Rating:
  • Currently 0.0/5 Stars from 50 ratings
  • 1
  • 2
  • 3
  • 4
  • 5
Categories: Conditional Array Loop Logic Error Debugging Process Eclipse
Description: click for more...

This video shows a program which is searching through an array, in a linear fashion, looking for a value. It has an if…else statement within a loop which assigns a boolean value to a variable called “found” every iteration of the loop (if theArray[index] == value). It shows that the code works for any value not in the array, but that it always reports “found” to be false, even for values that are in the array. By inserting print statements at the start of the if block and then in the else block, it shows that “found” is updated every iteration of the loop, potentially overwriting the assignment of true to “found.”