Consider the following definition in C programming: typedef struct node{ int data; struct node* next; }Node;...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Consider the following definition in C programming: typedef struct node{ int data; struct node* next; }Node; Which of the following statements should be used to create a new node? Select one: a. Node NewNode = (Node)malloc(sizeof(Node")); b. Node NewNode = (Node)malloc(sizeof(Node)); c. Node NewNode = (Node*)malloc(Node); d. Node NewNode = (Node)malloc(sizeof(Node)); Question 5 Not yet answered Marked out of 5.00 P Flag question What will the below function return for the following linked list? 1- >2->3->4->5->6 Note that head is a pointer to the first node. int Function(Node* head) { Node *ptr = head; int X = -3; ptr = ptr->next; ptr = ptr->next; while (ptr != NULL) { X += ptr->data; ptr = ptr->next; } return X; } Select one: a. 20 O O O d. 21 b. 15 c. 18 Question 7 Not yet answered Marked out of 5.00 P Flag question [5 points] Given the following function: int sum(int n) { if (n <= 1) return 1; else return n+sum(n-1); } To calculate sum(6), how many times is the recursive function sum called? Select one: a. 6 Ob.7. Oc.5 Od. 1 C Question 8 Not yet answered Marked out of 5.00 P Flag question Consider the following recursive function: void Function List(struct Node* ptr){ if(ptr == NULL) return; printf("%d\t", ptr); FunctionList(ptr->next); } If Function List(head) is called, and the linked list is not empty, what will happen? Select one: O ● a. The elements will be printed from head to tail. b. An error message will be displayed. c. The function will be executed an "infinity" of times. d. The elements will be printed in reverse order. Question 9 Not yet answered Marked out of 5.00 P Flag question Consider the following code: void FunctionArray(int A[], int i, int n){ if (i==n) } return; printf("%d\t", A[i]); FunctionArray(A, i+1, n); Assume you have an array A of ten elements. If printArray(A, 5, 10) is called, what will happen? Select one: O a. A[9] will be printed an "infinity" of times. b. A[o] will be printed an "infinity" of times. c. The elements in the array will be printed from A[5] to A[9]. d. The elements in the array will be printed in reverse order from A[9] down to A[5]. Question 6 Hot yet answered Marked out of 5.00 Flag question Which of the following statements is correct: Select one: O a. Any problem that can be resolved recursively can also be resolved iteratively. Ob. A program is called iterative when a function calls itself. c. Omitting the base case in a recursive function does not cause infinite recursion. d. A program is called recursive when there is a loop (or repetition). Consider the following definition in C programming: typedef struct node{ int data; struct node* next; }Node; Which of the following statements should be used to create a new node? Select one: a. Node NewNode = (Node)malloc(sizeof(Node")); b. Node NewNode = (Node)malloc(sizeof(Node)); c. Node NewNode = (Node*)malloc(Node); d. Node NewNode = (Node)malloc(sizeof(Node)); Question 5 Not yet answered Marked out of 5.00 P Flag question What will the below function return for the following linked list? 1- >2->3->4->5->6 Note that head is a pointer to the first node. int Function(Node* head) { Node *ptr = head; int X = -3; ptr = ptr->next; ptr = ptr->next; while (ptr != NULL) { X += ptr->data; ptr = ptr->next; } return X; } Select one: a. 20 O O O d. 21 b. 15 c. 18 Question 7 Not yet answered Marked out of 5.00 P Flag question [5 points] Given the following function: int sum(int n) { if (n <= 1) return 1; else return n+sum(n-1); } To calculate sum(6), how many times is the recursive function sum called? Select one: a. 6 Ob.7. Oc.5 Od. 1 C Question 8 Not yet answered Marked out of 5.00 P Flag question Consider the following recursive function: void Function List(struct Node* ptr){ if(ptr == NULL) return; printf("%d\t", ptr); FunctionList(ptr->next); } If Function List(head) is called, and the linked list is not empty, what will happen? Select one: O ● a. The elements will be printed from head to tail. b. An error message will be displayed. c. The function will be executed an "infinity" of times. d. The elements will be printed in reverse order. Question 9 Not yet answered Marked out of 5.00 P Flag question Consider the following code: void FunctionArray(int A[], int i, int n){ if (i==n) } return; printf("%d\t", A[i]); FunctionArray(A, i+1, n); Assume you have an array A of ten elements. If printArray(A, 5, 10) is called, what will happen? Select one: O a. A[9] will be printed an "infinity" of times. b. A[o] will be printed an "infinity" of times. c. The elements in the array will be printed from A[5] to A[9]. d. The elements in the array will be printed in reverse order from A[9] down to A[5]. Question 6 Hot yet answered Marked out of 5.00 Flag question Which of the following statements is correct: Select one: O a. Any problem that can be resolved recursively can also be resolved iteratively. Ob. A program is called iterative when a function calls itself. c. Omitting the base case in a recursive function does not cause infinite recursion. d. A program is called recursive when there is a loop (or repetition).
Expert Answer:
Answer rating: 100% (QA)
Answer Question 3 d Node NewNode Node mallocsizeofNode Option 1 is incorrect because ... View the full answer
Related Book For
Government and Not for Profit Accounting Concepts and Practices
ISBN: 978-1118155974
6th edition
Authors: Michael H. Granof, Saleha B. Khumawala
Posted Date:
Students also viewed these programming questions
-
What four methods can be used to create international advertising budgets?
-
What diene and what dienophile should be used to synthesize the following compounds? a. b. c. d. e. f. 0 2 OCH COCH COOH COOH
-
What criteria and ethical considerations should be used to select Parkinson patients for stem-cell therapy?
-
The system shown consists of 3 cables. For example; cable C12 joins points 1 and 2. The coordinates of point 1 are (6.4, 0, 0) m, those of point 2 are (0, 9.5, -6.1) m, and those of point 3 are (0,...
-
On January 1, Puckett Company paid $1.6 million for 50,000 shares of Harrisons voting common stock, which represents a 40 percent investment. No allocation to goodwill or other specific account was...
-
Bellati Inc. produces large industrial machinery. Bellati has a machining department and a group of direct laborers called machinists. Each machinist is paid $50,000 and can machine up to 500 units...
-
Consider the calculation of an external rate of return (ERR). The positive cash flows in the cash flow profile are moved forward to \(t=n\) using what value of \(i\) in the \((F \mid P i, n-t)\)...
-
The bank portion of the bank reconciliation for Rintala Company at November 30, 2014, was as follows. The adjusted cash balance per bank agreed with the cash balance per books at November 30. The...
-
Pioneer Inc. wants to invest $557,302 today. The expected returns in years 1, 2, and 3 are $247,615, $180,383, and $335,481, respectively. If the rate of return on investment must be at least 14%,...
-
Pear Corporation is a hypothetical company with financial results similar to Apple, Inc. Pear has been entering into a variety of financing transactions over the past few years, the results of which...
-
What is accounting and define its branches?
-
A WBS shows a work package called Window Sill Flashing as a child task of Exterior Masonry and Windows. Both parent work packages are at the same immediately preceding level in the WBS. The masonry...
-
Describe the procedures to be followed for the receiving and opening of bids. If possible, attend a bid opening and determine the number of bids that were submitted. For several unsuccessful bids...
-
Fudd Associates, Inc. submits a bid for $20 million. Mr. Fudd discovers at bid opening that all other bids are over $25 million. It is obvious that there is a mistake in his cost estimate. Could he...
-
Using OSHA regulations as a guide, determine what are the accepted safety standards for: a. Guard rails b. Exposed reinforcing steel c. Protection of openings d. Man hoists
-
What were the reasons that caused the real estate bubble of the early to mid-2000s to burst, which caused a recession? Do some research to justify your reasoning.
-
Company XYZ is experiencing declining sales and is in need of a turnaround strategy. As the newly appointed general manager, you are tasked with developing a plan to revive the company's performance....
-
The Taylor's series expansion for cosx about x = 0 is given by: where x is in radians. Write a user-defined function that determines cosx using Taylor's series expansion. For function name and...
-
In what way, if any, does the accounting equation as applied in governmental and not-for-prot accounting differ from that as applied in business accounting?
-
Refer to the transactions in the previous exercise. 1. Prepare journal entries that the city would make in its governmental funds (e.g., its general fund or a capital projects fund). 2. How would you...
-
Select the best answer. Items 1 through 5 refer to Riverview City. 1. Riverview City received a gift of $1 million. The sum is to be maintained as an endowment, with income used to preserve and...
-
As a security analyst covering the French market, youve identified the following factors and factor sensitivities for Elf Acquitaine (Elf): Elfs functional currency is the euro. Factors and factor...
-
Using the data shown in Figure 2.11 which anatomical site of the corn on the foot was the least frequently reported patients in the corn plaster group? The least frequently reported anatomical site...
-
The regional directors of a major investment bank are discussing investment strategies for their respective countries. a. As director of North American investments, describe to your foreign...
Study smarter with the SolutionInn App