MYPROGRAMMINGLAB WITH PEARSON ETEXT
8th Edition
ISBN: 9780134225340
Author: Deitel
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 12, Problem 12.20E
Program Plan Intro
Program plan:
- Item, start variablesare used for input. There is structure listnode havingdata, nextPtrmember variables which represents the linked listnode.
- void insert(node **head, int value) function inserts the node in the a linked list.
- node *printListBackward(node *head) function reverse the linked list and return the head which points to reverse linked list.
- void printList(node *head) function display the contents of the linked list.
Program description:
The main purpose of the program is to create a linked list by the value input by the user and then reverse that linked list recursively.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
: Write a recursive function to multiply two positive integers without usingthe * operator (or / operator). You can use addition, subtraction, and bit shifting, but you shouldminimize the number of those operations.
(Recursive Greatest Common Divisor) The greatest common divisor of integers x and y isthe largest integer that evenly divides both x and y. Write a recursive function gcd that returns thegreatest common divisor of x and y. The gcd of x and y is defined recursively as follows: If y is equalto 0, then gcd(x, y) is x; otherwise gcd(x, y) is gcd(y, x % y), where % is the remainder operator.
(In Python) Write a generator function that will take a number n and generate all of the combinations using the sequence of numbers, ex. N = 3, (0, 1, 2) and create all combination (0,0) (0,1) (0,2) (1,1) (1,2) (2,2) N! = 6 and show its operation in using it in a list and print its generation.
Chapter 12 Solutions
MYPROGRAMMINGLAB WITH PEARSON ETEXT
Ch. 12 - Prob. 12.6ECh. 12 - (Merging Ordered Lists) Write a program that...Ch. 12 - Prob. 12.8ECh. 12 - (Creating a Linked List, Then Reversing Its...Ch. 12 - Prob. 12.10ECh. 12 - Prob. 12.11ECh. 12 - Prob. 12.12ECh. 12 - Prob. 12.13ECh. 12 - Prob. 12.14ECh. 12 - (Supermarket Simulation) Write a program that...
Knowledge Booster
Similar questions
- (This question is for a linked list of the type described on the front page, Item 5). Write a recursive function CountGE60. that receives a linked list (may or may not be empty) and returns the number of nodes (each containing a data item value) greater than or equal to 60.arrow_forward(Data Structures and Algo C++ Weiss 4th ed - ch7.40): The following divide-and-conquer algorithm is proposed for finding the simultaneous maximum and minimum: If there is one item, it is the maximum and minimum, and if there are two items, then compare them, and in one comparison you can find the maximum and minimum. Otherwise, split the input into two halves, divided as evenly as possibly (if N is odd, one of the two halves will have one more element than the other). Recursively find the maximum and minimum of each half, and then in two additional comparisons produce the maximum and minimum for the entire problem. In C++, find a function which will take in a vector and solve the problem, producing a vector of two elements, the min and max.arrow_forwardUnder your module imports, paste the following definitions: (define WIDTH 300) (define HEIGHT 160) (define ES (empty-scene WIDTH HEIGHT)) (define (next-size s) (/ s 2)) Write a tail-call recursive function called circles in Racket. This function should take two numbers, x and size, and a Scene scn. If size is less-than or equal to 2, then your function returns the scn unchanged (base case). Otherwise, your function should place a circle in the Scene that results from a recursive call to circles with x shifted by (+size (next-size size)), a new size of (next-size size), and using the original Scene. After evaluating (circles 100 48 ES), your function should output this image of five blue circles, in this order, with the first circle at (x,y) coordinate position (100, 80):arrow_forward
- #python codecoud you provide comments and little explanation it would really help me to understandthankyouarrow_forwardWrite a recursive function to sort an array of integers into ascending order using the following idea: the function must place the smallest element in the first position, then sort the rest of the array by a recursive call. This is a recursive version of the selection sort. (Note: You will probably want to call an auxiliary function that finds the index of the smallest item in the array. Make sure that the sorting function itself is recursive. Any auxiliary function that you use may be either recursive or iterative.) Embed your sort function in a driver program to test it. Turn in the entire program and the output.arrow_forwardPYTHON: create a function code(n) that sorts a list of words alphabetically using a RECURSIVE function. tip: a. check if the length of n = 1, if true, return n and stop b. else, if the length of n >= 1, do the ff: c. get the min(x) (least rank word in alphabetical order) d. create a new array from n, where the min is removed. The new array is m. e. return the array composed of the min + code(m).arrow_forward
- Under your module imports, paste the following definitions: (define WIDTH 300) (define HEIGHT 160) (define ES (empty-scene WIDTH HEIGHT)) (define (next-size s) (/ s 2)) Next, write a tail-call recursive function called circles. This function should take two numbers, x and size, and a Scene scn. If size is less-than or equal to 2, then your function returns the scn unchanged (base case). Otherwise, your function should place a circle in the Scene that results from a recursive call to circles with x shifted by (+ size (next-size size)), a new size of (next-size size), and using the original Scene. After evaluating (circles 100 48 ES), your function should output this image of five blue circles, in this order, with the first circle at (x,y) coordinate position (100, 80):arrow_forwardlanguage: Python Problem: Write a recursive function reverse(sentence) for reversing a sentence. For example, reverse('Who let the dogs out?') will return '?tuo sgod eht tel ohW'. Also write a test case in the program to prove the function given works.arrow_forward2: - Write a recursive function that takes an array and a callback function and returns True if any value of that array returns True from that callback function otherwise returns False. As a callback funtion for this problem, assume that the callback function is used to check if a given input is an even number. Anals, the running time of the algorithm 3: Recursive Linear Searcharrow_forward
- Python Programming - (Duplicate Elimination) Part 1: Create a function that receives a list and returns a (possibly shorter) list containing only the unique values in sorted order. Test your function with a list of numbers and a list of strings. Program is to also display results, that's the sorted list containing values. Part 2: Instead of hard coding the list passed to the sorting functions, request list values from user. (Hint: Request two lists from user, one containing values and another containing string.) Have the program eliminate duplicated values and display the lists (tasks required in part 1).arrow_forwardCreate a recursive function that multiplies two positive integers without the need of the * (or /) operator. You can utilise addition, subtraction, and bit shifting, but you should keep the amount of operations to a minimum.arrow_forwardCodeW X b For func x C Solved X b Answer X https://codeworkou... CodeWorkout X270: Recursion Programming Exercise: Count Characters For function countChr() write the missing part of the recursive call. This function should return the number of times that the letter "A" appears in string "str". Recall that str.substring(a) will return the substring of str from position a to the end of str, while str.substring (a, b) will return the substring of str starting at position a and continuing to (but not including) the character at position b. Examples: countChr ("ctcoWCAt") -> 1 Your AnsSwer: 1 public int countChr(String str) { 2. if (str.length() return 0; } (0 4. { int count = 0; www. 5. 9. if (str.substring(0, 1).equals("A")) { count = 1 7. { 9. return count + > 1:10 AM 50°F Clear 12/4/2021 呼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