1__Questions_LL_15

1__Questions_LL_15 - this list Write a fragment of code to...

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

View Full Document Right Arrow Icon
CIS 15BG Questions Chapter 15 LINKED LISTS 1. Imagine we have a linked list as shown below. What would happen if we apply the following statements to the list? Draw "the answer". Note that each statement does not affect the other statements and it is only based upon the original assumptions: Assume : p->data = 10; q->data = 20; r->data = 15; and that p points to the first node in the list, q to the second, r to the third, and t to the last one. (A). p = p->link; (B). q = p; (C). r = p->link; (D). q->data = r->data; (E). p->data = q->link->data; (F). t->link = p; 2. A NODE in a linked list has two fields: part , a structure of type PART, and next , a pointer to the next node. The PART structure has three fields: code , an integer, name , a 1 p q r p q r p q r p q r p q r p q r t t t t t t
Background image of page 1

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

View Full DocumentRight Arrow Icon
CIS 15BG Questions Chapter 15 LINKED LISTS dynamically allocated string, and an array of 10 suppliers' codes (also integers) named sAry . (A). Write the definition for the NODE and PART structures. (B). Assume you have a linked list of parts, and a pointer pCurr, to one of the nodes in
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: this list. Write a fragment of code to print the part code, name and the list of its suppliers' codes for the part in the node pointed by pCurr. 2 CIS 15BG Questions Chapter 15 LINKED LISTS 3. Imagine we have a linked list as shown below. The node has two fields: num , an integer, and link , a pointer to the next node. The list is not sorted and contains 4 integers: 50, 25, 90, and 75. (A). What would happen if we call the following function? Draw "the answer" . (This function has no application use). int fun( NODE *pList ) { NODE *p1; NODE *p2; p2 = NULL; p1 = pList; while( p1->link != NULL ) { p2 = p1; p1 = p1->link; } p1->link = p2; p2 = p2->link; return p2->num; } (B). What would be returned from the function? (C). Show how would you call it from main() int main( void ) { NODE *pList; // assume a buildList function is called here return 0; } 3 pList...
View Full Document

Page1 / 3

1__Questions_LL_15 - this list Write a fragment of code to...

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

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