Programming in C
4th Edition
ISBN: 9780321776419
Author: Stephen G. Kochan
Publisher: Addison-Wesley
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 10, Problem 2E
Write a function called to insert a new entry into a linked list. Have
the procedure take as arguments a pointer to the list entry to be inserted (of type s e as defined in this chapter), and a pointer to an element in the list after which the new e is to be inserted.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
You are given the pointer to the head node of a linked list and an integer to add to the list. Create a new node with the given integer. Insert this node at the tail of the linked list and return the head node of the linked list formed after inserting this new node. The given head pointer may be null, meaning that the initial list is empty.
Function Description
Complete the insertNodeAtTail function in the editor below.
insertNodeAtTail has the following parameters:
SinglyLinkedListNode pointer head: a reference to the head of a list
int data: the data value for the node to insert
Returns
SinglyLinkedListNode pointer: reference to the head of the modified linked list
Input Format
The first line contains an integer , the number of elements in the linked list.The next lines contain an integer each, the value that needs to be inserted at tail.
Constraints
Sample Input
STDIN Function ----- -------- 5 size of linked list n = 5 141 linked list data values…
Write a function that has two linked-list head pointers as parameters. Assume that the linked list's items are
ordered by the 2-> 33 ->4 -> 5
=>1-> 2-> 3-> 3-> 4 ->5
Write a function that changes the places of the first and second nodes of a linked list. I.e. the First node will become the second node, and the second node will become the first node.
THE FUNCTION WILL NOT EXCHANGE DATA, IT WILL CHANGE LINKS.
Chapter 10 Solutions
Programming in C
Ch. 10 - Type in and run the 15 programs presented in this...Ch. 10 - Write a function called to insert a new entry into...Ch. 10 - Prob. 3ECh. 10 - Write a function called r to remove an e from a...Ch. 10 - Prob. 5ECh. 10 - Prob. 6ECh. 10 - Prob. 7ECh. 10 - Prob. 8ECh. 10 - Prob. 9ECh. 10 - Prob. 10E
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
What is the difference between the names defined in an ML let construct from the variables declared in a C bloc...
Concepts of Programming Languages (11th Edition)
The _________ is the part of a computer with which the user interacts. a. central processing unit b. user inter...
Starting Out with Programming Logic and Design (4th Edition)
What output is produced by the following code? int count = 0; while (count 5) { System.out.println(count); cou...
Java: An Introduction to Problem Solving and Programming (7th Edition)
_____ is data the computer collects from the world outside of the computer.
Starting Out With Visual Basic (7th Edition)
The ________ object is assumed to exist and it is not necessary to include it as an object when referring to it...
Web Development and Design Foundations with HTML5 (8th Edition)
What is the difference between a text file and a binary file?
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 1. Suppose you have already developed an SLL ADT. You have to search a specificelement of the linked list. If you find the element in the list then you have to swapits previous node with its next node. Otherwise, simply print the message “Datanot found”. Now write a function in your SLL ADT with this functionality.arrow_forward1.In a linear linked list, write a function named changeFirstAndLast that swaps the node at the end of the list and the node at the beginning of the list. The function will take a list as a parameter and return the updated list. 2. A singly linear list stores integer values in each node and has multiple nodes. Write a function using given prototype below. This function cuts the first node of the list and adds it to the end as last node. It takes beginning address of the list as a parameter and returns the updated list.struct node* cutheadaddlast(struct node* head);struct node { int number; struct node * next; }; 3.Adding the even numbers to the beginning of the list and odd numbers to the end of the list until -1 is entered from keyboard.struct node { int number; struct node * next; }; 4.Write a function that takes two parameters head (list name) and age (given student age). The function deletes node (free this memory location) by finding the second node with the given age value in…arrow_forwardin C++ kth ElementExtend the class linkedListType by adding the following operations:a. Write a function that returns the info of the kth element of the linked list. If no such element exists, terminate the program.b. Write a function that deletes the kth element of the linked list. If no such element exists, terminate the program. Provide the definitions of these functions in the class linkedListType. please, do not copy from any other sources, give me a fresh new code. Thank youarrow_forward
- complete the following function. // It is the same as observeCounter except that f has a parameter of type List[Counter] not Counter. // f will insist that the List[Counter] has length 3. // You must return a List[Int] not an Int. // The first element of the result List[Int] must correspond to the number of times that increment/decrement were called on the first element of type List[Counter], similarly for the second and third elements. def observeCounterList (f : List[Counter] => Unit) : List[Int] = { // TODO: Provide definition here. List (-1, -1, -1) }arrow_forwardCreate the function initialize_list(n, value) that takes as a parameter an integer n and a value. It creates 4 lists with length 10 where the initializers are taken from the list [ ‘*’, 10, 12.0 , -1], i.e. one list is all *s, another all 10’s etc. (Expected output is shown in the image attached)arrow_forward2. Suppose you have already developed an SLL ADT. You have to search a specific element of the linked list. If you find the element in the list then you have to swap its previous node with its next node. Otherwise, simply print the message “Data not found". Now write a function in your SLL ADT with this functionality.arrow_forward
- InterpolationAssignment DescriptionMeike, our climate scientist, was very happy with the program you wrote to calculate the maximum temperature drop. Now she has the following problem; in a series of measurements shediscovers one data point is missing, but not which one. She does know that the measurementsshow a constant increase.Write a function, interpolate(list), that completes a given series. Provide as output the indexbehind which the element should be inserted and the value. You can assume that the measurements are natural numbers and that the input consists of at least 3 measurements. You can assumethat both the first and the last data point have not been droppedP.S. Meike is in a hurry; your algorithm must run in O(log n) time.ExampleInput Output 1 Output 2[1, 2, 4] 1 3[3, 7, 11, 19] 2 15NotesMake sure to turn in your code with the filename “Interpolation.py”. If you turn it in withany other name it will fail the tests. This is due to instead of this assignment giving you an…arrow_forwardPart I Implementation In this part you are asked to write functions with python . Define a two dimensional list with NxN elements. This list should be filled with random numbers between 100 and 200. . Write a function that takes a table as a parameter and prints list elements with table shape • Write a function that takes a table as a parameter and return a list that holds diagonal (left-top corner to bottom-right) elements. Write a function that takes a table as a parameter and returns number of all odd numbers in the table Note: You are not allowed to use Numpy package. Part II Testarrow_forward3. Write a function to return the median value in a sorted linked list. If the length i of the list is odd, then the median is the ceiling(i/2) member. For example, given the list (1, 2, 2, 5, 7, 9, 11) as input, your function should return the value 5. If the length of the list is even, then the median is the mean of the i/2 and (i/2)+1 members. Thus, the median of the sorted list (2, 4, 8, 9) is (4+8)/2. Finally, define the median of an empty list to be 0.arrow_forward
- Write a function that takes two parameters head (list name) and age (given student age). The function deletes node (free this memory location) by finding the second node with the given age value in the list. Write the required function using the prototype given below.node* deleteNode(node*, int);arrow_forwardImplement a function to remove all occurrences of a specific element from a list.arrow_forwardImagine we have a linked list as shown below. The ListNodehas two fields: num, an integer, and next, a pointer to the next node. The list is not sorted. Write the definition of a function that calculates and returns the sum of the numbers in the list.arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Introduction to Linked List; Author: Neso Academy;https://www.youtube.com/watch?v=R9PTBwOzceo;License: Standard YouTube License, CC-BY
Linked list | Single, Double & Circular | Data Structures | Lec-23 | Bhanu Priya; Author: Education 4u;https://www.youtube.com/watch?v=IiL_wwFIuaA;License: Standard Youtube License