Computer Science CS50 Lecture Notes - Linked List, Insertion Sort, Graham Scan

26 views8 pages

Document Summary

Linked list: maintain pointer to first node in a linked list; insert/remove from front. Array: use array s[] to store n items on stack. Underflow: throw exception if pop from an empty stack. Holding a reference to an object when it is no longer needed. https://cs. ericyy. me/algorithms-1/week-2/index. html. Already pop up the n-th item, should set it null before return. Resizing array stack push(): double size of array s[] when array is full. pop(): halve size of array s[] when array is one-quarter full. Linked list: maintain pointer to first and last nodes in a linked list; Use array q[] to store items in queue. enqueue(): add new item at q[tail]. dequeue(): remove item from q[head]. In iteration i, find index min of smallest remaining entry. Assume left side is already sorted, then in iteration i, swap a[i] to the left if a[i] < a[i-1] Move entries more than one position at a time by h-sorting the array. https://cs. ericyy. me/algorithms-1/week-2/index. html.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions