Node * List_insert(Node * head, int v)
{
  printf("insert %d\n", v);
  Node * p = Node_construct(v); 
  p -> next = head;
  return p;   /* insert at the beginning */
}
Example #2
0
File: 0709.c Project: kuos/ECE264
Node * List_insert3(Node *front, int val)
{
  if(front == NULL)
    {
	return Node_construct(val);
    }
	
  Node * p = front;

  while ((p->next)!= NULL)
    {
      p = p->next;
    }

  p -> next = Node_construct(val);
  return front;
  
  //IF RETURN P 

}
Example #3
0
File: 0709.c Project: kuos/ECE264
Node * List_insert2(Node * front, int val)
{
  if(front == NULL)
    {
      return Node_construct(val);
    }

  front -> next = List_insert2(front->next, val);
  return front;
  // if front is null retun new node, or else it returns front.
  // front->next = front->next
}
Example #4
0
File: 0709.c Project: kuos/ECE264
Node * List_insertSort(Node * front, int val)
{
  if(front == NULL)
    {
      return Node_construct(val);
    }
  if((front->data) > val)
    {
      Node * n = Node_constrcut(val);
      n-> next = front;
      return n;
    }

  //can use a while loop
  front->next = List_insertSort(front->next, val);
  //when reached, the return n in the 
  //if loop will make the link to the previous val
  return front;
}
Example #5
0
File: 0709.c Project: kuos/ECE264
Node * List_insert(Node * front, int val)
{
	Node * n = Node_construct(val);
	n -> next = front;
	return n;
}