Skip to content

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

binary-search-one-test

Binary Search — One Test Inside Loop

Exercise 3-1 (from The C Programming Language)

This exercise improves the classic binary search by reducing the number of tests inside the loop from two to one.

Original version:
Checks if x < v[mid] and else if x > v[mid] on each loop.

Optimized version:
Uses only if (x <= v[mid]) inside the loop and checks equality only once outside.

Files

  • binsearch.c — Original version
  • binsearch_one_test.c — Optimized version
  • main.c — Runs both and measures runtime
  • Makefile — Easy build

How to build & run

make
./main

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages