As already said, there is some ambiguity in finding the index of an element: If you search the five elements 1 2 2 3 4 for the value 2 the program returns the index 3 not 2. UNTIL found OR (high ![]() ![]() Another hint is that you should avoid the test of booleans to false/true: Just use them, i.e. Your code can be changed easily to get the index of a found element (note that I wrote a not the because there may be more than one element with the search value): You just plugin the index of the compared element if the values are the same, this additionally improves the code. JELASKAN KONSEP RECORD,ARRAY,TOP, PADA STACK JAWABAN 1. JELASKAN PERBEDAAN TOP DENGAN MAX STACK 4. IF found=true THEN writeln('ELEMENT FOUND') BERIKAN SATU CONTOH PENERAPAN STACK DALAM KEHIDUPAN SEHARI-HARI 3. Writeln('what number do you want to search?') This is what i found on the internet but this code only tell you if the number the user wants to search is found or not. Could someone please help me out program binSearch ![]() I have been struggling for hours to create this code and it's still not complete. I want to create binary search in pascal.
0 Comments
Leave a Reply. |