Trace the method binarySearch, as given in Segment 18.13, when searching for 4 in the following array of values: 5 8 10 13 15 20 22 26 30 31 34 40 Repeat the trace when searching for 34.
last resort, use else statement. Cannot put anything after the “else” expression or it won’t read it only “if” and “end” are needed the “elseif” and and “else” are not NEEDED >> %Day 7 MATLAB examples >> a=10;b=15;c=20; >> x=a> y=a>c||b> %one means yes, zero means no >> z=a>c&&b> %these are 3 logical operators >> v=x&y v = 1 >> %if x is true and y is true, you should get a true for v as well >> %string compare syntax is "strcmp('Yes','No') >> %ex. s1='upon';s2={'Once','Upon','A','Time'};tf=strcmp(s1,s2) >> s1='upon';s2={'Once','Upon','A','Time'};tf=strcmp(s1,s2) tf = 0 0 0 0 >> %It's comparing each thing and saying yes this is true (1)