C Language ProgramI have a sorted array, but it has been shifted. .docx - C Language Program I have a sorted array but it has been shifted I need a

C Language ProgramI have a sorted array, but it has been shifted. .docx

This preview shows page 2 - 5 out of 5 pages.

C Language ProgramI have a sorted array, but it has been shifted. I need a function "search" that would find the key value in the array and also analyze its worst case performace. The output should return the index of the entered key.#include#include#define NEW(x) (x*)malloc(sizeof(x))typedef int DATA;typedef struct node{ void * data;struct node * next;} NODE;typedef struct{ long num;NODE * head;NODE * tail;}ROOT;NODE * make_node (void *data){ NODE * temp;temp = NEW(NODE);if (temp != NULL){ temp->data = data;temp->next = NULL;}return temp;}
Background image
ROOT * make_root (void){ ROOT * temp;temp = NEW(ROOT);if (temp != NULL){ temp->num = 0;temp->head = NULL;temp->tail = NULL;}return temp;}void display_list(ROOT *r){ NODE * temp;if (r != NULL){ temp = r->head;do{ printf("%3d ", *(DATA *)(temp->data));temp = temp->next;} while (temp != NULL);
Background image
Background image
Background image

You've reached the end of your free preview.

Want to read all 5 pages?

  • Spring '14
  • Gilbert,Joanne

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture

  • Left Quote Icon

    Student Picture