CMPT 225 Lecture Notes - Lecture 3: Binary Logarithm, Linear Search, Quicksort

66 views3 pages

Document Summary

Copy constructor and assignment operator for linked list stack void mystack::deepcopy(const mystack & st) top = null; if (st. top != null) { // copy the top copy = new node(original->data, null); top = copy; original = original->next; while (original != null) { copy->next = new node(original->data, null); copy = copy->next; original = original->next; Will basically make a copy of any linked list that has a single pointer to the front of the list. Going to have to deal with stacks that already exist, have to get rid of them somehow. // kill everything in stack temp = top->next; delete top; top = temp; Mystack & mystack::operator= (const mystack & st) if (this != &st) { deletestack(); deepcopy(st); Recursive functions do not use loops to repeat instructions. Recursive functions will have at least 2 cases: base case and recursive case. Base can be implicit. (if false, do nothing as example) Base case is smaller problem with smaller solution.

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