Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "Operations.h"
- void printLinkedList(PNODE head) {
- do {
- printf("%d -> ", head->data);
- } while ((head = getNextNode(head)) != NULL);
- printf("NULL");
- }
- //TODO:
- _Bool findElement(PNODE head, int data) {
- while (head != NULL)break;
- return false;
- }
- //add traverse comparison with this vs. array using clock()
- PNODE traverse_a(PNODE head, int distance) {
- if (head != NULL) {
- if (distance) {
- while ((--distance) && (head->next != NULL))head = head->next;
- }
- else {
- while (head->next != NULL)head = head->next;
- }
- }
- return head;
- }
- PNODE insertNormal(PNODE head, int data, int *size) {
- PNODE cur = traverse_end(head);
- //printf("%x", cur);
- //_getch();
- if (cur)
- cur = (cur->next = getNewNode());
- else
- cur = calloc(1, NODESIZE);
- cur->data = data;
- (*size)++;
- return ((head)?head:cur);
- }
- PNODE deleteNormal(PNODE head, int* size) {
- if (head != NULL) {
- PNODE cur = traverse(head, (*size) - 1), tmp = NULL;
- if (*size != 1) {
- tmp = cur;
- cur = getNextNode(cur);
- tmp->next = NULL;
- }
- free(cur);
- (*size)--;
- return (((*size)) ? head : NULL);
- }
- return NULL;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement