# SYSC 2006 Study Guide - Summer 2018, Comprehensive Midterm Notes - Linked List, Integer, Function Pointer

234 views21 pages
SYSC 2006
MIDTERM EXAM
STUDY GUIDE
Fall 2018
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 21 pages and 3 million more documents.

Unlock document

This preview shows pages 1-3 of the document.
Unlock all 21 pages and 3 million more documents.

find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 21 pages and 3 million more documents.

find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows pages 1-3 of the document.
Unlock all 21 pages and 3 million more documents.

## Document Summary

Introduction: a si(cid:374)gl(cid:455) li(cid:374)ked list is (cid:449)here e(cid:448)er(cid:455) (cid:374)ode is (cid:272)o(cid:374)(cid:374)e(cid:272)ted to other (cid:374)ode. A head poi(cid:374)ter is a poi(cid:374)ter to the list"s first (cid:374)ode (cid:894)a. k. a. the head (cid:374)ode(cid:895) A tail poi(cid:374)ter is a poi(cid:374)ter to the last (cid:374)ode (cid:894)a. k. a the tail (cid:374)ode(cid:895) to de(cid:272)rease ru(cid:374)(cid:374)i(cid:374)g ti(cid:373)e of t(cid:455)pedef stru(cid:272)t i(cid:374)t(cid:374)ode { i(cid:374)t (cid:448)alue; stru(cid:272)t i(cid:374)t(cid:374)ode *(cid:374)e(cid:454)t; } i(cid:374)t(cid:374)ode_t: nodes i(cid:374) the si(cid:374)gl(cid:455) li(cid:374)ked lists are (cid:373)odelled (cid:271)(cid:455) a(cid:374) i(cid:374)t(cid:374)ode_t "t(cid:455)pe, value stores a(cid:374) i(cid:374)teger a(cid:374)d (cid:374)e(cid:454)t stores a poi(cid:374)ter to the (cid:374)et (cid:374)ode i(cid:374) the list. Ho(cid:449) to create a node: i(cid:374)t(cid:374)ode_t *i(cid:374)t(cid:374)ode_(cid:272)o(cid:374)stru(cid:272)t(cid:894)i(cid:374)t (cid:448)alue, i(cid:374)t(cid:374)ode_t *(cid:374)e(cid:454)t(cid:895) i(cid:374)t(cid:374)ode_t *ptr; ptr = (cid:373)allo(cid:272)(cid:894)sizeof(cid:894)i(cid:374)t(cid:374)ode_t(cid:895)(cid:895); // assert(cid:894)ptr != null(cid:895); ptr->(cid:448)alue = (cid:448)alue; ptr->(cid:374)e(cid:454)t = (cid:374)e(cid:454)t; retur(cid:374) ptr; New section 1 page 1: what this (cid:272)ode does is: Allo(cid:272)ate a(cid:374)d i(cid:374)itialize a (cid:374)ode o(cid:374) the heap, a(cid:374)d retur(cid:374) a poi(cid:374)ter to the (cid:374)ode. The last node"s (cid:374)e(cid:454)t al(cid:449)a(cid:455)s (cid:272)o(cid:374)tai(cid:374)ed null.