subject

Consider the following code: // Linked Lists: TRAVERSE

struct ListNode { int data; struct ListNode *next; };

Assume that a linked list has been created and head points to a sentinel node. A sentinel node is an empty data node in the beginning of the list. It sometimes holds a sentinel value. The use of sentinel nodes is a popular trick to simplify the insert and delete operations.

You may also assume that the list is not empty. Each node in the list contains an integer representing a digit in a number. The data in the sentinel node is -1.

For instance, n = 234 will be stored as {-1, 4, 3, 2} in the linked list.

Write a function based on the list traversal named computeNumFromList that is passed the pointer to the first node in the list, it prints the digits in the list one per line, and it returns a long integer, the number calculated from its digits in the list (234 see the above example). You may assume that long int will hold the converted number (no need to check for numeric overflow).

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 07:20
Write a pseudocode solution for each of these problems. 1. design a while loop that lets that user enter a number. the number should be multiplied by 10, and the result stored in a variable named product. the loop should iterate as long as product contains a value less than 100. 2. design a do-while loop that asks the user to enter two numbers. the numbers should be added and the sum displayed. the loop should ask the user whether he or she wishes to perform the operation again. if so, the loop should repeat; otherwise it should terminate. 3. design a for loop that displays the following set of numbers: 0, 10, 20, 30, 40, 50 100. 4. design a nested loop that displays 10 rows of # characters. there should be 15 # characters in each row. 5. convert this for loop to a while loop. declare integer count for count = 1 to 50 display count end for 6. find the error in the following pseudocode. declare boolean finished = false declare integer value, cube while not finished display β€œenter a value to be cubed.” input value; set cube = value ^ 3 display value, β€œ cubed is β€œ, cube end while
Answers: 2
question
Computers and Technology, 22.06.2019 22:30
The qwerty keyboard is the most common layout of keys on a keyboard
Answers: 3
question
Computers and Technology, 23.06.2019 12:00
Which of these is an example of an integrated presentation? a. a table created in powerpoint b. an image pasted into powerpoint c. a caption created in powerpoint d. an excel chart pasted into powerpoint
Answers: 1
question
Computers and Technology, 24.06.2019 10:10
Which view in a presentation program displays a split window showing the slide in the upper half and a blank space in the lower half?
Answers: 1
You know the right answer?
Consider the following code: // Linked Lists: TRAVERSE

struct ListNode { int data; struc...
Questions
question
Mathematics, 13.01.2021 17:30
question
Mathematics, 13.01.2021 17:30
question
Mathematics, 13.01.2021 17:30
Questions on the website: 13722367