Last active
August 29, 2015 14:01
-
-
Save DrewWeth/d7c614552b99a05a9c56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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