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,...
-
What would be your annualized discount rate % and your annualized investment rate % on the purchase of a 182-day Treasury bill for $4,925 that pays $5,000 at maturity?
-
Solve each linear programming problem. Maximize z = 5x + 2y subject to x 0, y 0, x + y 10, 2x + y 10, x + 2y 10
-
How can you formally obtain discovery of information about the adverse party posted on a social media site?
-
On January 1, 2017, Schipper Ltd. had the following shareholders' equity accounts: Common shares (1,000,000 issued)......................$1,500,000 Retained...
-
Rory Company has an old machine with a book value of $77,000 and a remaining five-year useful life. Rory is considering purchasing a new machine at a price of $105,000. Rory can sell its old machine...
-
A process is in control with x = 100.s = 1.05, and n = 5. The process specifications are at 95 ± 10. The quality characteristic has a normal distribution. (a) Estimate the potential...
-
Directions: Be sure to save an electronic copy of your answer before submitting it to Ashworth College for grading. Unless otherwise stated, answer in complete sentences, and be sure to use correct...
-
How do matrix organizational structures reconcile the need for cross-functional collaboration with the potential for conflicting lines of authority, and what best practices can be adopted to minimize...
-
Zachary Delivery is a small company that transports business packages between New York and Chicago. It operates a fleet of small vans that moves packages to and from a central depot within each city...
-
2. A new computer costs $1,500. It loses 5% of its value each year after it is purchased. Determine the value of the computer after 24 months. You must include an equation with your solution. /4
-
Monty Corporation issued $588,000 of 6% bonds on May 1, 2025. The bonds were dated January 1, 2025, and mature January 1, 2028, with interest payable July 1 and January 1. The bonds were issued at...
-
Sycamore Systems sold $5 million worth of software on December 1, 20X1 to a Japanese company with payment denominated in Japanese yen to be received in two months. Sycamore's year end is 31st...
-
Monique is a manager at a firm based in Chicago. She has recently been selected to manage the firm's Singapore office along with three other managers from the Chicago office. The firm hopes that the...
-
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...
-
Imagine you are a decision-maker about to allocate millions of dollars to-ward an SoS. The analysts have told you that the SoS configuration they recommend was developed using an agent-based model....
-
Choose one of the items below to complete: a. Prepare an abstraction depiction /paper model and complete pseudo-code that would implement a fire escape ABM for a university class-room. Pseudo-code...
-
Discuss THREE possible reasons why an entitys gross profit margin might increase from one year to the next.
Study smarter with the SolutionInn App