a.) function that deletes last node.
public ListNode deleteLast(ListNode head)
{
if(head == NULL) //if Linked List is
empty then Null is return
return head;
if(head->next == NULL) // if
linked list has only one element, then head is deleted
{
head = NULL;
return head;
}
ListNode* currNode = head;
while (currNode->next &&
currNode->next->next != NULL) //while loop finds
the last element in Linked List
{
currNode =
currNode->next;
}
currNode->next = NULL;
return head;
}
B.) function that delete all duplicate nodes.
// the working of the function is same as bubble sort, we will compare each node value with every node in Linked List and if we find the duplicate then we will delete it
void delete_duplicates(struct LinkedList *head)
{
struct LinkedList *ptr1, *ptr2, *dup;
ptr1 = head;
/* Pick elements one by one */
while (ptr1 != NULL && ptr1->next !=
NULL)
{
ptr2 = ptr1;
/* while loop to Compare
the elements */
while (ptr2->next !=
NULL)
{
/* If duplicate then delete it */
if (ptr1->data == ptr2->next->data)
{
dup = ptr2->next;
ptr2->next = ptr2->next->next;
delete(dup);
}
else
ptr2 = ptr2->next;
}
ptr1 =
ptr1->next;
}
}
SLL, 25 pts] (back variable is NOT available) (10 pts) Introduce a function that deletes last...
2) (10 pts) Write a function that takes in a pointer to a linked list of nodes storing integers and a variable named value, and returns the number of nodes in the list storing that value. For example, if a list pointed to by listPtr stores 2, 6, 2, 3, 4, 2, 6, and 6 and value = 6, your function should return 3, since 6 appears in the list 3 times. Please use the struct and function prototype provided...
1) (10 pts) Write a recursive function that counts and returns the number of nodes in a binary tree with the root root, that store an even value. Please use the struct shown and function prototype shown below. (For example, if the tree rooted at root stored 2, 3, 4, 8, 13, 18 and 20, the function should return 5, since there are five even values [2,4,8,18,20] stored in the tree. typedef struct node { int data; struct node* left;...
Question 2.)Let A= student id last digit % 4 and add 1. For example mine student id is 7. So 7%4=3 and add 1 -->A=4 Run DFS starting at node a, and breaking ties alphabetically(in this case numerically as nodes have numbers where 1 goes before 2). Please label just back edges. 3 2 6 2 8 1 3 5 4 3
4. [10 pts] Let X be a random variable with probability density function if 1 < a < 2, 2 f(a)a 0 otherwise. Find E(log X). Note: Throughout this course, log = loge.
Score on last try: 0,5 of 1 pts. See Details for more. > Next question You can retry this question below Graphing Linear Functions Identify the Slope and Intercepts of the function f(x) function. = 3z. Then draw an accurate graph of the T5 10- f(z) = 3 %3D Slope 15 -10 10 y-intercept x-intercept -10- 15+ Clear All Draw: Question Help: D Video Submit Question
1. [10 pts.] AVL Trees: Example Operations
(a) [5 pts.] Draw the AVL tree that results from inserting key
45 into the following AVL
tree.
(b) [5 pts.] Draw the AVL tree that results from deleting key 70
from the following AVL
tree. NOTE: When deleting a key from an AVL tree, please follow the
textbook approach
of finding the node with the key using the function for standard
binary search trees.
If the key is in the tree and...
3-) Let ocr<1 o w UUUUU is probability destiny function of X random variable. a- ) Find PlOCXCI) b.) Find Pix > 15) UUUUUU ca) Find € (x) and Var(x) d-) Find the distribution function
This Question: 2 pts 1 of 4 (0 complete) The function graphed is of the form y- a sin bx or y a cos bx, where b> 0. Determine the equation of the graph. y(Use integers or fractions for any numbers in the expression.)
1. static int function(int n){ return n * function(n + 1); } If you call the method function(2), the expected output is 3. True False 2. public void push(int new_data) { Node new_Node = new Node(new_data); new_Node.next = head; new_Node.prev = null; if (head != null) head.prev = new_Node; head = new_Node; } The code snippet depicts stack implementation True False 3. A ________ list is a linked data structure that consists of a set of sequentially linked records called...
1. (10 points) Let X be a continuous random variable with the probability density function given by f(x)-4z if 0SaS1 and O otherwise (a) Find P(X sjIx> j) (b) Find the expectation and variance of X