예제 #1
0
파일: heap.c 프로젝트: sabraham/ds
int test_heap_arr_pop_min () {
  size_t arr_len = 10;
  size_t heap_size = 0;
  int *arr = init_heap(arr_len);
  heap_arr_insert(arr, 7, &heap_size, &arr_len);
  heap_arr_insert(arr, 7, &heap_size, &arr_len);
  heap_arr_insert(arr, 2, &heap_size, &arr_len);
  print_heap_arr(arr, arr_len);
  int popped = pop_min(arr, &heap_size);
  print_heap_arr(arr, arr_len);
  printf("popped: %d\n", popped);
  int expected[] = {7, 7};
  int ret = 0;
  ret += arrs_equal(arr, expected, heap_size);
  free(arr);
  ret += popped == 2 ? 1 : 0;
  return ret;
}
예제 #2
0
파일: heapify.c 프로젝트: rishdas/algo
int main()
{
    int arr[] = {-1, 27, 17, 3, 16, 13, 10, 1, 5, 7, 12, 4, 8, 9, 0};
    heap_t heap;
    heap.arr = arr;
    heap.size = 15;
    heap.heap_size = 14;
    max_heapify(heap, 3);
    print_heap_arr(heap);
}