

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


int triangle(int a, int b, int c) { if (a == b) if (b == c) return 1; else return 2; else if (b == c) return 2; else return 3; } boolean isPrime (int n) { // assume n > 2 for (int i = 2; i * i < n; i++) { if (0 == n % i) return false; } return true; }
An Active Learning approach to Data Structures using C 2
int binarySearch(double data [ ], int n, double test) { /* assume data is sorted / int low = 0; int high = n; while (low < high) { mid = (low + high) / 2; if (data[mid] == test) return 1; / return true / if (data[mid] < testValue) low = mid + 1; else high = mid; } return 0; / return false */ }
int leapDays (int year) { if ((year % r) == 0) || ((year % 100 == 0) && (year % 400 == 0)) return 28; else return 29; }