11 Assembly

11 Assembly - !"#"$$ $ CMSC 216...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: !"#"$$ $ CMSC 216 Introduction to Computer Systems Lecture 11 Linked Lists (cont) & Assembly Language Programming Jan Plane & Pete Keleher {jplane, keleher}@cs.umd.edu Administrivia Project 3a & Project 3b Read Chapter 11, Reek Exam mean = 69% CMSC 216 - Wood, Sussman, Herman, Plane 2 !"#"$$ & Deleting from a linked list CMSC 216 - Wood, Sussman, Herman, Plane 3 5 8 12 NULL head 6 3 Tracing deletion int delete(Node **head, int value) { Node *prev = NULL, *current = *head; while (current != NULL && current->data != value) { prev = current; current = current->next; } if (current == NULL) return 0; /* not found */ if (prev != NULL) prev->next = current->next; else *head = current->next; /* deleted first item */ free(current); return 1; } CMSC 216 - Wood, Sussman, Herman, Plane 4 !"#"$$ ! Doubly linked lists We can have references in both directions Allows use of only one pointer when performing some operations typedef struct dl_node { struct dl_node *prev; struct dl_node *next; int val; } DL_node; CMSC 216 - Wood, Sussman, Herman, Plane 5 Deletion from a doubly linked list int delete(DL_node **root, int target) { DL_node *current; for (current = *root; current != NULL; current = current->next) if (current->val == target) break; if (current == NULL) return 0; if (current == *root) *root = current->next; else current->prev->next = current->next; if (current->next != NULL) current->next->prev = current->prev; free(current); return 1; } CMSC 216 - Wood, Sussman, Herman, Plane 6 !"#"$$ ! Doubly linked lists We can have references in both directions Allows use of only one pointer when performing some operations typedef struct dl_node { struct dl_node *prev; struct dl_node *next; int val; } DL_node; CMSC 216 - Wood, Sussman, Herman, Plane 5 Deletion from a doubly linked list int delete(DL_node **root, int target) { DL_node *current; for (current = *root; current != NULL; current = current->next) if (current->val == target) break; if (current == NULL) return 0; if (current == *root) *root = current->next; else current->prev->next = current->next; if (current->next != NULL) current->next->prev = current->prev; free(current); return 1; } CMSC 216 - Wood, Sussman, Herman, Plane 6 !"#"$$ ' A SSEMBLY L ANGUAGE Chapters 3 and 4.1, Bryant and O'Hallaron CMSC 216 - Wood, Sussman, Herman, Plane 7 Assembly language The CPU uses machine language to perform all its operations Assembly is a much more readable translation of machine language, and it is what we work with if we need to see what the...
View Full Document

Page1 / 12

11 Assembly - !"#"$$ $ CMSC 216...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online