2__Questions_LL_15

2__Questions_LL_15 - 3. Imagine we have a linked list as...

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

View Full Document Right Arrow Icon
CIS 15BG Questions Chapter 15 LINKED LISTS 1. Which one of the following fragments of code is incorrect? Why? 2. 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. Write the definition of a function that calculates and returns the sum of the numbers in the list. 1 pList
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
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 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. (A). Write a function that swaps the first and the second node in the list (do not swap data). Assume the list has more than two nodes. HINT: define two local pointer variables, p1 and p2, and initialize them to point to the first and second node respectively. (B). Show how would you call it from main() int main( void ) { NODE *pList; // assume a buildList function is called here return 0; } 2 pList...
View Full Document

Page1 / 2

2__Questions_LL_15 - 3. Imagine we have a linked list as...

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

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