Question: **Please provide the answer in python** Given a node define as : def class node : int data; node next; 1) Write a function getAverage(Head)

**Please provide the answer in python**

Given a node define as :

def class node:

int data;

node next;

1) Write a function getAverage(Head) that will take head of a singly linked list and return the average.

2) Write a function numOfOccurrences(Head, value) that will take Head of a singly linked list and return the number of occurrences of the value in the list.

3) Youre given the pointer to the head nodes of two singly linked lists. Compare the data in the nodes of the linked lists to check if they are equal. The lists are equal only if they have the same number of nodes and corresponding nodes contain the same data.

4) Assume, Head is the head-node of a singly linked list (sll). Write a utility function addNodeBeforeValue (self, givenValue, newValue) to insert a new value in this sll just before the given value.

a. If the given value is found in the sll, insert the new value just before the given value. b. If the given value is not found, dont add the node. Just print Not found

5) Remove the even numbers from the following singly linked list. Write a utility function deleteeven(self) that will delete all even nodes from the singly linkedlist

6) Write a utility function function named sorted_insert(self, v) that takes a parameter v and inserts it into a singly linked list in ascending order.

7) Assume there is a singly linked list. HEAD is the pointer for head node. Write a function reverseList(HEAD) to reverse the linked list. It means, the function will return the new head.

8) Assume, HEAD is the head-node of a doubly linked list (dll). Write a utility function addNodeAfterValue(self, givenValue, newValue) to insert a new value in this dll just after a given value.

a) If the given value is found in the dll, insert the new value just after the given value.

b) If the given value is not found, dont add the node. Just print Not found

9) Given a sorted doubly linked list and a value to insert, write a function to insert the value in sorted way (and in efficient way). Initial doubly linked list

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!