C Programming language Part 1: You need to define a data structure for a doubly linked list and a binary search tree. Also, you need to implement the following functions: Insert Sorted LINKEDLIST insertSorted(LINKEDLIST head, int num): head points to the first node in the sorted linked list; num is a number to be inserted in in correct place in the linked list pointed at “head”. The linked list should be sorted after inserting “num”. This function returns the head of the modified head. BSTREE insert(BSTREE root, int num): root points to a node in a binary search tree; num is a number to be inserted in the tree rooted at “root”. This function returns the root of the modified tree. Find an element LINKEDLIST find(LINKEDLIST head,int num): head points to the first node of a linked list; num is a number to be searched for in the linked list started at “head”. This function returns a pointer to the node containing “num” or NULL if num is not found BSTREE find(BSTREE root,int num): root points to the root of a binary search tree; num is a number to be searched for in the tree rooted at “root”. This function returns a pointer to the node containing “num” or NULL if num is not found. Print Elements void LinkedListTraversal(DLINKEDLIST head, FILE *fp): head points to the first node in a linked list. This function does not return anything, but prints out, to the file specified, the nodes in the doubly linked list pointed by “head”. void inorderTraversal(BSTREE root, FILE *fp): root points to a node in a binary search tree. This function does not return anything, but prints out, to the file specified, the nodes in the tree rooted at “root” by performing an inorder traversal.
Types of Linked List
A sequence of data elements connected through links is called a linked list (LL). The elements of a linked list are nodes containing data and a reference to the next node in the list. In a linked list, the elements are stored in a non-contiguous manner and the linear order in maintained by means of a pointer associated with each node in the list which is used to point to the subsequent node in the list.
Linked List
When a set of items is organized sequentially, it is termed as list. Linked list is a list whose order is given by links from one item to the next. It contains a link to the structure containing the next item so we can say that it is a completely different way to represent a list. In linked list, each structure of the list is known as node and it consists of two fields (one for containing the item and other one is for containing the next item address).
C Programming language
Part 1: You need to define a data structure for a doubly linked list and a binary search tree. Also, you need to implement the following functions:
-
Insert Sorted
-
LINKEDLIST insertSorted(LINKEDLIST head, int num): head points to the first node in the sorted linked list; num is a number to be inserted in in correct place in the linked list pointed at “head”. The linked list should be sorted after inserting “num”. This function returns the head of the modified head.
-
BSTREE insert(BSTREE root, int num): root points to a node in a binary search tree; num is a number to be inserted in the tree rooted at “root”. This function returns the root of the modified tree.
-
-
Find an element
-
LINKEDLIST find(LINKEDLIST head,int num): head points to the first node of a linked list; num is a number to be searched for in the linked list started at “head”. This function returns a pointer to the node containing “num” or NULL if num is not found
-
BSTREE find(BSTREE root,int num): root points to the root of a binary search tree; num is a number to be searched for in the tree rooted at “root”. This function returns a pointer to the node containing “num” or NULL if num is not found.
-
-
Print Elements
-
void LinkedListTraversal(DLINKEDLIST head, FILE *fp): head points to the first node in a linked list. This function does not return anything, but prints out, to the file specified, the nodes in the doubly linked list pointed by “head”.
-
void inorderTraversal(BSTREE root, FILE *fp): root points to a node in a binary search tree. This function does not return anything, but prints out, to the file specified, the nodes in the tree rooted at “root” by performing an inorder traversal.
-
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 8 images