HOMEWORKREF

HOMEWORKREF - Fall 2005 1 Tri Le Homework Review Homeworks...

Info iconThis preview shows pages 1–4. 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: Fall 2005 1 Tri Le Homework Review Homeworks Review ASSIGNMENT 2: STACK Data structure of STACK:- a container object that is defined by behavior: o Last In, First Out (LIFO) o First In, Last Out (FILO) - Basic operation: o Push: insert into the stack o Pop: remove from the stack o Top: viewing of the top stack item Allocate memory: Void pointer in heap -> malloc return without a type. Void pointer: turn off type checking of compiler. Deallocated memory: free: work together with malloc (malloc stores the amount of memory allocated). & free know how much and where to look. Fall 2005 2 Tri Le Homework Review ASSIGNMENT 3: LIST Data structure of LIST: Single link list: - One front pointer, optional end pointer. - Multiple nodes with nest pointers - The end of the List has a NULL next pointer. - Problems / limitations: & Only go forward: (solution: double link list). & Separate code to insert / remove in the middle / end. & Optional end pointer -> faster accessing to the end . Double link list:- front and end pointer - Nodes with next and pre - End of the List has next pointer with value of NULL. - Front of the List has pre pointer with value of NULL. - Problems / limitations: & Separate code to insert/ remove at the front/end/middle & Solved by implementing a circular linked list. Circular link list:- One front pointer and /or one end pointer. Multiple Nodes with nest and pre pointers. - The front and the end of the list are implied through use. - Benefit: & Inserting/ Removing from the front/middle and is inserting/removing between two Nodes. Insert/Remove at front, additionally update front pointer. Insert/Remove at end, additionally update the end pointer (if we had an end). & One set of code to perform the Node insertion regales of the location in the list where the insertion occurs. Polymorphic Generic Container approaching: container can store anything How? Link list can store anything by using void pointer Where? In List.c in struct Node: void * data; Constraint for hw3 for enforcing homogeneous container Function pointers: The class must have these below function pointers in order for its object to be inserted in the container - is_equals: determine equality - delete: deallocate the object - write: write out object to user Driver 1: new allocates an object. Driver 2: copy copies an object. Fall 2005 3 Tri Le Homework Review Pointer in link list: - Pointers point to the beginning memory allocated for that Node. - Nodes are allocated in the heap - The List is in the heap too & The Nodes/List objects allocated from the heap are nameless....
View Full Document

Page1 / 15

HOMEWORKREF - Fall 2005 1 Tri Le Homework Review Homeworks...

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

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