Skip to content

Instantly share code, notes, and snippets.

@DrewWeth
Last active August 29, 2015 14:01
Show Gist options
  • Save DrewWeth/d7c614552b99a05a9c56 to your computer and use it in GitHub Desktop.
Save DrewWeth/d7c614552b99a05a9c56 to your computer and use it in GitHub Desktop.
/*
Pretend like Strings are actually a thing
*/
typedef struct node{
String value;
Node* next;
} Node;
// Inserts to the front of the list
Node* insert (Node* head, String value){
Node* temp = createNode(value); // pretend like createNode is already written
if (head == null)
return temp;
temp->next = head;
return temp;
}
Node* createNode (String value);
{
Node* temp = malloc(sizeof(Node));
temp->value=value;
temp->next = NULL;
return temp;
}
// Prints interatively
void printDaList (Node* head)
{
if (head == null)
return;
Node* temp= head;
while (temp->next != null)
{
printf("%s", temp->value);
temp = temp->next;
}
printf("%s", temp->value);
}
/* Maintain these two hash relations and delete can be O(1)
Hash(String value, int count)
Hash(int count, Node* reference)
*/
int delete (Node* head, String value)
{
}
int main ()
{
Node* head = null;
head = insert(head,"Shane.");
head = insert(head,"and ");
head = insert(head,"Ryan ");
head = insert(head,"You ");
head = insert(head,"Thank ");
printDaList(head);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment